这里的程序是使用OCI驱动程序创建一个表,但它显示以下错误。
import java.sql.*;
public class CreateTable{
public static void main(String[] args)throws Exception{
Connection con;
Statement ps;
String query;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:oci8:orcl","scott","tiger");
query="CREATE TABLE Employee (roll number(3))";
ps=con.createStatement();
ps.executeUpdate(query);
System.out.println("Table created");
ps.close();
con.close();
}
}
答案 0 :(得分:-1)
试试这个:
try (
Connection conn = DriverManager.getConnection(
"jdbc:oracle:oci8:orcl","scott","tiger"); // MySQL
Statement ps = conn.createStatement();
{
String query="CREATE TABLE Employee (roll number(3))";
ps=con.createStatement();
ps.executeUpdate(query);
System.out.println("Table created");
System.out.println("Table created");
}
} catch(SQLException ex) {
ex.printStackTrace();
}
ps.close();
con.close();
}
}
最好使用Type 4 Connectivity,因为他们的Java驱动程序是“直接到数据库”。