62,621
社区成员
发帖
与我相关
我的任务
分享
private final static String user="system";
private final static String password="chenwei";
private final static String url="jdbc:oracle:thin:@localhost:1521:orcl";
private final static String className="oracle.jdbc.driver.OracleDriver";
public static void main(String[] args) {
System.out.println(insert("chenwei","1234"));
}
public static Connection getConnection(){
Connection con=null;
try {
Class.forName(className);
con=DriverManager.getConnection(url, user, password);
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
public static boolean insert(String userName, String password) {
boolean flag = false;
String sql = "insert into 'system'.'user' values(?,?)";
Connection con = null;
PreparedStatement ps = null;
try {
con = getConnection();
ps = con.prepareStatement(sql);
ps.setString(1, userName);
ps.setString(2, password);
int count = ps.executeUpdate();
flag = count > 0 ? true : false;
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
java.sql.SQLException: ORA-00903: invalid table name