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 jdbc odbc?

737


What is statement and preparedstatement in java?

651


What is JDBC DataSource and what are it’s benefits?

718


What is the use of JDBC DriverManager class?

743


What is an advantage of using the jdbc connection pool?

650


What is the execute method in java?

730


What is the use of the statement in jdbc?

681


What do you understand by jdbc statements?

708


What is JDBC Driver interface?

774


How to connect multiple database in jdbc?

708


How can we retrieve the file in the oracle database?

719


What are the utilities of the callablestatement?

720


What is jdbc drivers in java?

648


What is a jdbctemplate?

692


What is db client?

711