日期:2014-05-19 浏览次数:20947 次
public static void main(String[] args) throws ClassNotFoundException, SQLException { String url="jdbc:oracle:thin:@192.168.1.4:1521:performancedb"; String driverClass="oracle.jdbc.driver.OracleDriver"; String name="ywk"; String password="password"; Class.forName(driverClass); Connection connection= DriverManager.getConnection(url,name,password); Statement statement =connection.createStatement(); ResultSet resultSet= statement.executeQuery("select * from t_user"); System.out.println(resultSet); }
Exception in thread "main" java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connection descriptor used by the client was: 192.168.1.4:1521:performancedb at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:185) at com.a.b.TestJDBC.main(TestJDBC.java:16)