我正嘗試使用JDBC驅動程序連接到Oracle數據庫,並且處理了一個錯誤:「java.sql.SQLException:指定了無效的Oracle URL」。在java中使用JDBC連接到數據庫
我的代碼如下:
import java.sql.*;
public class L9
{
public static void main(String args[])
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin;@localhost:1521:xe","user","password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from table");
while(rs.next())
System.out.println(rs.getInt(1) + " "+rs.getString(2)+ " "+rs.getString(3));
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
任何人都知道這是什麼問題?
更換'; '在'瘦'之後加上':' –