Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Type Mismatch: Cannot convert from Connection to Connection

843859Jul 13 2007 — edited Nov 20 2014
import java.sql.DriverManager;

public class Connection {
	
	public static Connection getDatabaseConnection(){
		Connection con = null;
		try{
			// load the driver
			DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
			// get the connection
			con = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:bob", "scott", "tiger");

			if(con != null){
				System.out.println("Connection established Successfully at port : "+1521);
			}else{
				System.out.println("Could not establish Connection");
			}
		}
		catch (Exception e){
			e.printStackTrace();
			con = null;
		}
		return con;
	 }

}
Error pointing on line

con = DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:bob", "scott", "tiger");

Type Mismatch: Cannot convert from Connection to Connection

I have included the classes12.jar file as an external Jar file for the project.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2010
Added on Jul 13 2007
3 comments
1,139 views