Popular Feed

Create database connection in Oracle using java JDBC

 Below is the code to connect to oracle DB using JDBC APIs.

We need the below-listed jars as well.

ojdbc6.jar

jconn3.jar

public static Connection getQAConnection() throws ClassNotFoundException {

try {

Class.forName("oracle.jdbc.OracleDriver");  

conn=DriverManager.getConnection("jdbc:hostname:1521/dbname","user","password");

return conn;

} catch (SQLException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return null;  

}



No comments: