数据库用的是oracle 10g
连接jar什么classes12 ojdbc14 正常的oracle jar包都试过了
大家帮看看啊 一直卡在中文这个地方 太奇怪了
Oracle数据字符集是SIMPLIFIED CHINESE.ZHS16GBK
可以手动在数据库里面插入中文 且不是乱码
public class Jdbc_to_oracle {
public static void main(String[] args) throws SQLException {
String url="jdbc:oracle:thin:@localhost:1521:kzgsz";
String oracle_Driver="oracle.jdbc.driver.OracleDriver";
Connection conn = null;
PreparedStatement prestm;
try {
Class.forName(oracle_Driver);
conn = DriverManager.getConnection(url, "zz", "zz");
prestm=conn.prepareStatement("insert into T_TEST(id,name) values (8,?)");
//There is a point to note that is in jdbc,? is begin with 1,but in hibernate it begin with 0
//very important
System.out.println("1111111111111");
prestm.setString(1, "中文");
System.out.println("2222222222222");
prestm.executeUpdate();
System.out.println("3333333333333");
} catch (Exception e) {
// TODO: handle exception
}
finally
{
try {
conn.close();
} catch (Exception e2) {
// TODO: handle exception
}
}
}
}
输出:
1111111111111
2222222222222
就是无法插入