如上面我有一個問題,以「選擇數據庫」值java.sql.SQLException:沒有數據庫中選擇
我使用XAMPP,在那裏,我創造了在MySQL數據庫中,並把它命名爲「僱員」
這是我的Java代碼:
public static void main(String[] args) {
Connection conn = null;
Statement stmt = null;
try{
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection("jdbc:mysql://localhost?user=root&password=");
//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = "SELECT id, first, last, age FROM employees";
ResultSet rs = stmt.executeQuery(sql);
正如在「SQL」我試圖達到數據庫看出,採用FROM employees
我是新來與數據庫編程。 我是否需要找到數據庫的路徑?如何以及在哪裏可以找到它?