- 博客(0)
- 资源 (6)
- 收藏
- 关注
JDK1.8中文API.chm
JDK1.8中文API,网上资源比较少。基本都是英文版本,这版翻译的还算过得去。有需要的童鞋可以拿走。不像有些无道德的人,放一些无关的东西来骗取分数。
2017-08-22
bonecp连接池
在用C3P0数据连接池的时候,一旦并发上来就坑不住了,因为C3P0存在BUG,c3p0在从连接池中获取和返回连接的时候,采用了异步的处理方式,使用一个线程池来异步的 把返回关闭了(没有真正关闭)的连接放入连接池中。这样就意味着,我们在调用了从c3p0获得的连接的close方法时,不是立即放回池中的,而是放入一 个事件队列中等待c3p0内部的线程池顺序的处理。这里给出bonecp连接池,用了就知道好了
#bonecp properties
#分区数量
bonecp.partitionCount = 1
#每个分区含有的最小连接数
bonecp.minConnectionsPerPartition = 1
#每个分区含有的最大连接数
bonecp.maxConnectionsPerPartition = 2
#每次新增连接的数量
bonecp.acquireIncrement = 1
#连接池阀值,当 可用连接/最大连接 < 连接阀值 时,创建新的连接
bonecp.poolAvailabilityThreshold = 20
#连接超时时间阀值,获取连接时,超出阀值时间,则获取失败,毫秒为单位
bonecp.connectionTimeout = 10000
#连接池助手线程数量,可设置为0,该参数会降低运行速度,但程序有大量连接时,有助于提升高并发程序的性能
bonecp.releaseHelperThreads = 0
#语句助手线程数,可设置为0,该参数会降低运行速度,但程序有大量的查询语句时,有助于提升高并发程序的性能
bonecp.statementReleaseHelperThreads = 0
#测试连接有效性的间隔时间,单位分钟
bonecp.idleConnectionTestPeriod = 60
#连接的空闲存活时间,当连接空闲时间大于该阀值时,清除该连接
bonecp.idleMaxAge = 240
#语句缓存个数,默认是0
bonecp.statementsCacheSize = 5
在Hibernate中使用BoneCP除了需要上面提到的jar包之外,还需要下载一个名为bonecp-provider-0.7.0.jar的bonecp-provider的jar包,它的下载位置是:http://jolbox.com/bonecp/downloads/maven/com/jolbox/bonecp-provider/0.7.0/bonecp-provider-0.7.0.jar。
除此之外,还需要做如下配置:
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean" autowire="autodetect">
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.provider_class">com.jolbox.bonecp.provider.BoneCPConnectionProvider</prop>
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
<prop key="hibernate.connection.url">jdbc:mysql://127.0.0.1/yourdb</prop>
<prop key="hibernate.connection.username">root</prop>
<prop key="hibernate.connection.password">abcdefgh</prop>
<prop key="bonecp.idleMaxAge">240</prop>
<prop key="bonecp.idleConnectionTestPeriod">60</prop>
<prop key="bonecp.partitionCount">3</prop>
<prop key="bonecp.acquireIncrement">10</prop>
<prop key="bonecp.maxConnectionsPerPartition">60</prop>
<prop key="bonecp.minConnectionsPerPartition">20</prop>
<prop key="bonecp.statementsCacheSize">50</prop>
<prop key="bonecp.releaseHelperThreads">3</prop>
</props>
</property>
</bean>
2014-05-23
jfreechart-1.0.13
public class ZhuZhuang extends ApplicationFrame {
public ZhuZhuang(String s) {
super(s);
setContentPane(createDemoBar());
}
// 生成显示图表的面板
public static JPanel createDemoBar() {
JFreeChart jfreechart = createChart(createDataset());
return new ChartPanel(jfreechart);
}
// 生成图表主对象JFreeChart
public static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart3D("水果销量统计图", //建立3D柱状图
"水果",//横轴名称
"销量",//纵轴名称
dataset,//数据集
PlotOrientation.VERTICAL,//纵向显示
true,//显示每个颜色柱子的柱名
false, false);
CategoryPlot plot = chart.getCategoryPlot();//设置图的高级属性
BarRenderer3D renderer = new BarRenderer3D();//3D属性修改
renderer.setBaseOutlinePaint(Color.BLACK);//设置边框颜色为black
renderer.setWallPaint(Color.gray); //设置wall的颜色为gray
renderer
.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());//设置柱顶数据,API中居然没有StandardCategoryItemLabelGenerator这个类
//renderer.setItemLabelFont(new Font("黑体",Font.PLAIN,12));//设置柱顶数据字体
renderer.setItemLabelsVisible(true);//打开ItemLabel开关
plot.setRenderer(renderer);//将修改后的属性值保存到图中
plot.setForegroundAlpha(0.6f);//柱的透明度
return chart;
}
// 生成数据
public static CategoryDataset createDataset() {
double[][] data = new double[][] { { 672, 766, 223, 540, 126 },
{ 325, 521, 210, 340, 106 }, { 332, 256, 523, 240, 526 } };// 设置数据
String[] rowKeys = { "苹果", "梨子", "葡萄" };// 行标志
String[] columnKeys = { "北京", "上海", "广州", "成都", "深圳" };// 列标志
CategoryDataset linedataset = DatasetUtilities.createCategoryDataset(
rowKeys, columnKeys, data); // 建立数据集
return linedataset;
}
public static void main(String[] args) {
ZhuZhuang fjc = new ZhuZhuang("柱状图");
fjc.pack();
RefineryUtilities.centerFrameOnScreen(fjc);
fjc.setVisible(true);
}
}
2010-12-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人