我嘗試使用以下Java代碼連接到數(shù)據(jù)庫(kù):try { String connectionURL = "jdbc:mysql://11.11.111.111:3306/srfms"; Connection connection = null; Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "root", "password"); if(!connection.isClosed()) out.println("Successfully connected to " + "MySQL server using TCP/IP..."); connection.close(); }catch(Exception ex){ out.println(ex); } 這段代碼可以成功運(yùn)行,但是我還必須運(yùn)行另一個(gè)Spring MVC代碼,但是該代碼不起作用,這是database.properties:jdbc.driverClassName=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql:////11.11.111.111:3306/srfmsjdbc.username=rootjdbc.password=password錯(cuò)誤是:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:未知數(shù)據(jù)庫(kù)'srfms'編輯: jdbc.url = jdbc:mysql:////11.11.111.111:3306 / srfms:有兩個(gè)額外的“ /”是我的問(wèn)題。問(wèn)題解決了。
添加回答
舉報(bào)
0/150
提交
取消