how can connection with oracle10g with java

Answer Posted / kishan

package dao;
import java.sql.Connection;
import java.sql.DriverManager;
public class Database {
static final String USERNAME="hr";
static final String PASSWORD="hr";

public static Connection getConnection()
{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:XE",
USERNAME, PASSWORD);
return con;
}
catch(Exception ex) {
System.out.println(ex.getMessage());
return null;
}
}
}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of dialect?

570


I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?

485


How can I retrieve a String or other object type without creating a new object each time?

584


Why do you use a data source object for a connection?

548


What are the steps required to execute a query in jdbc?

534






What is the full form of jdbc?

495


What is jdbc driver manager?

501


What is the use of jdbc api?

511


Discuss the procedure of retrieving warnings?

561


Is jdbc a middleware?

510


What is resultset?

576


Is jdbc object oriented?

506


Which of the attributes in the monitoring tab for a jdbc connection pool in the administrative console tell us how many clients are currently waiting for a connection?

527


What is jdbc and odbc in java?

500


How we store procedure in oralce for callable statements in jdbc

1854