I can't get my post to be excepted.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I can't get my post to be excepted.
I am a Java beginner.
I am trying to connect to our oracle database through Eclipse. I have the following package.
We are at Oracle 11g Java 1.7 I have the ojdbc7.jar driver downloaded and placed in the classpath.
Yet I keep getting the error below:
No sure if this is an Eclipse problem, my code, or both.
//connection code package testConnect; import java.sql.*; import oracle.jdbc.OracleDriver; public class JdbcThinTnsNamesTest { public JdbcThinTnsNamesTest() { System.setProperty("oracle.net.tns_admin", "$TNS_ADMIN"); } public static Connection getConnection() throws SQLException { String username = "user"; String password = "password"; String thinConn = "jdbc:oracle:thin:@//NCPP"; DriverManager.registerDriver(new OracleDriver()); Connection conn = DriverManager.getConnection(thinConn, username, password); conn.setAutoCommit(false); return conn; } // public void run() throws SQLException { Connection conn = getConnection(); System.out.println("Auto Commit = " + conn.getAutoCommit()); conn.close(); } public static void main(String[] args) { JdbcThinTnsNamesTest test = new JdbcThinTnsNamesTest(); try { test.run(); System.out.println("all done.."); } catch (SQLException e) { e.printStackTrace(); } } } package oracle.jdbc; import java.sql.Connection; import java.sql.Driver; import java.sql.DriverPropertyInfo; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import java.util.logging.Logger; public class OracleDriver implements Driver { @Override public Connection connect(String url, Properties info) throws SQLException { // TODO Auto-generated method stub return null; } @Override public boolean acceptsURL(String url) throws SQLException { // TODO Auto-generated method stub return false; } @Override public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { // TODO Auto-generated method stub return null; } @Override public int getMajorVersion() { // TODO Auto-generated method stub return 0; } @Override public int getMinorVersion() { // TODO Auto-generated method stub return 0; } @Override public boolean jdbcCompliant() { // TODO Auto-generated method stub return false; } @Override public Logger getParentLogger() throws SQLFeatureNotSupportedException { // TODO Auto-generated method stub return null; } }
java.sql.SQLException: No suitable driver found for jdbcracle:thin:@//NCPP
at java.sql.DriverManager.getConnection(DriverManager .java:596)
at java.sql.DriverManager.getConnection(DriverManager .java:215)
at testConnect.JdbcThinTnsNamesTest.getConnection(Jdb cThinTnsNamesTest.java:17)
at testConnect.JdbcThinTnsNamesTest.run(JdbcThinTnsNa mesTest.java:24)
at testConnect.JdbcThinTnsNamesTest.main(JdbcThinTnsN amesTest.java:32)
Looks like it's referring to this line. Have you checked if the library is withinimport oracle.jdbc.OracleDriver;
the Eclipse build project files? If the driver is missing perhaps it's a botch install?
Try downloading the library again and linking it with your project.
Wishes Ada xx
If to Err is human - then programmers are most human of us all.
"The Analytical Engine offers a new, a vast, and a powerful language . . .
for the purposes of mankind."
— Augusta Ada Byron, Lady Lovelace (1851)
Try to explicitly load the database driver prior to trying to make the connection
Class.forName("oracle.jdbc.driver.OracleDriver");
Thanks Ada,
Followed your suggestion. Ran program again and get the following errror.
Error: Could not find or load main class oracle.sql.CharacterSetFactory