STATUS: Closed
Scenario:
While getting a thin client connection to the database (without using datasource) using the below code:
Connection myLink = DriverManager.getConnection("jdbc: oracle:thin:@127.0.0.1:1521:xe", "testuser", "testpassword");
Statement myStatement = myLink.createStatement();
we get a SQLException as follows:
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@127.0.0.1:1521:x eat java.sql.DriverManager.getConnecti on(DriverManager.java:602)at java.sql.DriverManager.getConnecti on(DriverManager.java:185)...
Resolution:
Add the following line of code before getting the connection:
Class.forName("oracle.jdbc.driver. OracleDriver");
Possible Root Cause:
The driver manager needs to be registered in order to get a connection.
No comments:
Post a Comment