[英]org.apache.derby.jdbc.ClientDriver ; unable to connect
Unable to connect.无法连接。 Cannot establish a connection to jdbc:derby://localhost:1527/sample using org.apache.derby.jdbc.ClientDriver (DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ040, SQLERRMC: Failed to start database 'sample' with class loader sun.misc.Launcher$AppClassLoader@1d44bcfa, see the next exception for details.::SQLSTATE: XSLAN).无法使用 org.apache.derby.jdbc.ClientDriver 建立到 jdbc:derby://localhost:1527/sample 的连接(DERBY SQL 错误:ERRORCODE:40000,SQLSTATE:XJ040,SQLERRMC:无法使用类启动数据库“sample” loader sun.misc.Launcher$AppClassLoader@1d44bcfa,详情参见下一个异常。::SQLSTATE: XSLAN)。
When you do a connection you should put it into a try/catch.当您进行连接时,您应该将其放入 try/catch 中。 For example ( I use Java 8 and oracle SQLDeveloper ) :例如(我使用 Java 8 和 oracle SQLDeveloper):
String dbURL="jdbc:oracle:thin:@localhost:1521:xe";
String username = "system";
String password = "root";
try{
Connection connection = DriverManager.getConnection(dbURL,username,password);
System.out.println("Connected to Oracle database server");
String sql = "INSERT INTO USERS (name,email,password)" + "VALUES('eu', 'eu@yahoo.com', 'eu')";
Statement statement = connection.createStatement();
int rows = statement.executeUpdate(sql);
if(rows >0){
System.out.println("A row has been inserted");
}
connection.close();
}catch (SQLException e){
System.out.println("ERROR");
}
And always check for right password and username.并始终检查正确的密码和用户名。 Hope this helps.希望这可以帮助。 :D :D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.