我在执行我的代码时遇到此错误,该代码应该以批处理模式处理 SQL 语句:
ORA-03115: 不支持的网络数据类型或表示
这是运行时生成错误的代码:
public class Login {
public static void main(String args[]) throws SQLException {
Connection con = null;
PreparedStatement stmt = null;
Statement st = null;
try {
Driver driver = new oracle.jdbc.driver.OracleDriver();
DriverManager.registerDriver(driver);
System.out.println("coneecting to the database:");
con = DriverManager.getConnection("url", "user", "pass");
con.setAutoCommit(false);
System.out.println("creating statement");
String sql = "insert into shweta values(?,?)";
stmt = con.prepareStatement(sql);
printrows(stmt);
stmt.setString(1, "love");
stmt.setInt(2, 45);
stmt.addBatch();
stmt.setString(1, "kaun");
stmt.setInt(2, 29);
stmt.addBatch();
int count[] = st.executeBatch();
con.commit();
printrows(stmt);
// printRs(rs);
st.close();
stmt.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
try {
if (con != null)
con.rollback();
} catch (SQLException en) {
en.printStackTrace();
}
}
catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (stmt != null)
stmt.close();
} catch (Exception e) {
}
try {
if (con != null)
con.close();
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println("good bye ashish");
}
public static void printrows(Statement stmt) throws SQLException {
String sql = "select * from shweta";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
// Retrieve by column name
int age = rs.getInt("age");
String first = rs.getString("auth");
System.out.print(", Age : " + age + "\n");
System.out.print("AUTH : " + first + "\n");
}
System.out.println();
}
}
我是编码新手,不确定如何解决此错误,感谢所有帮助。谢谢。