急,急,急(求教高人)
求教高手,下边代码有何错误?如何改?
package oraclejdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import
java.sql.SQLException;
import com.sun.org.apache.bcel.internal.generic.FALOAD;
//批处理
public class Orjdbc5 {
private String driver = "oracle.jdbc.driver.OracleDriver ";
private String url= "jdbc:oracle:thin:@192.168.0.60:1521:oraclejj ";
private String user = "scott ";
private String password = "tiger ";
private Connection conn = null;
private PreparedStatement ps = null;
Orjdbc5() {
try {
Class.forName(driver);
} catch (
ClassNotFoundException e) {
e.printStackTrace();
}
}
public void open() {
try {
conn = DriverManager.getConnection(url, user, password);
conn.setAutoCommit(false);
} catch (
SQLException e) {
e.printStackTrace();
}
}
public boolean caozuo() {
boolean n = false;
open();
try {
ps=conn.prepareStatement( " desc lianxi ");
ps.addBatch( "insert into lianxi(id) values(168) ");
ps.addBatch( "insert into lianxi(id) values(118) ");
ps.executeBatch();
conn.commit();
n = true;
} catch (Exception e) {
e.printStackTrace();
try {
conn.rollback();
} catch (SQLException e1) {
e.printStackTrace();
}
} finally {
close();
}
return n;
}
public void close() {
try {
conn.setAutoCommit(true);
if (ps != null) {
ps.close();
ps = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Orjdbc5 o = new Orjdbc5();
boolean b = o.caozuo();
System.out.print(b);
}
}
------解决方案--------------------把你的错误信息弄上来!
------解决方案--------------------数据库有问题没?