Hibernate3.2是否和MYSQL5.1不兼容兼容
解决方案 »
- 怎么在cmd命令框里检查某台ftp服务器的ftp功能是否正常?
- jfreechart X轴显示问题,回答挨到边得也有分哦
- Java Web应用需要集成域用户登陆问题
- 利用Spring配置RMI的问题?请教。谢谢。
- ejb小白的问题-关于stateless bean
- xfire 中如何定义复杂类型
- 有关使用反射机制与JavaBean取数据记录并输出的问题。
- 有高人在吗?这儿有两道测试题,谁能帮忙提供一下思路?
- tomcat下使用jxl操作excel的问题
- 在sco unix 5.0 版本上要用哪个weblogic版本?怎么安装?
- 懂MQ的java高手进,被MQ传送文件给难住了~~~~
- ireport菜单栏中字体列表中的中文字体名怎么都是乱码,
我要一百分.
下面有个例子 你们看1下 ,它就插入了1行,结果返回7810893而不是 J2EE说的-2(唯一正确值),并且返回7810893的同时,可以插入到数据库中package jdb;import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;public class TestBatch {
public static Connection getConnection() throws SQLException,IOException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver");
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream("config.property"));
props.load(in);
in.close();
return DriverManager.getConnection(props.getProperty("url"),
props.getProperty("user"),
props.getProperty("password"));
}
public static Statement getState(Connection con) throws SQLException, IOException, ClassNotFoundException{
return con.createStatement();
}
public static Statement addBatch(Statement state, String[] sql) throws SQLException, IOException, ClassNotFoundException {
if (sql.length <1){
System.out.println("no sql batch");
}
else{
//System.out.println(sql.length);
for (int i=0;i<sql.length;i++){
state.addBatch(sql[i]);
}
return state;
}
return null;
}
public static void close(Connection state) throws SQLException {
state.close();
}
public static void main(String[] args) {
String[] sql = {"insert into events values(3,'2007-01-06','qiuting')"};
try{
Connection con = TestBatch.getConnection();
Statement stat = TestBatch.getState(con);
TestBatch.addBatch(stat, sql);
int[] res = stat.executeBatch();
TestBatch.close(con);
for (int i=0; i<res.length; i++){
System.out.println("return values "+res[i]);
}
System.out.println("ok");
}catch(Exception e){
System.err.println(e);
}
finally{
}
}
}
要是驱动的问题,那5.1应该使用哪个版本的驱动呢?