Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

anybody know how to link jsp with oracle??

Status
Not open for further replies.

juanferman

Programmer
Nov 14, 2001
40
US
Hi guy.

Anybody know how to link jsp with oracle??

thanks a lot
===================
::) Juan F. Sarria
 
You can make a DB connection thru JDBC.

Class.forName("oracle.jdbc.driver.OracleDriver");
connection=DriverManager.getConnection(myUrl,myUserid,myPassword);

i.e. if your DB name is "abc", your port number is 1521, and your host name is "xyz" then myUrl="jdbc:eek:racle:thin:mad:abc:1521:xyz"
 
I use this class:

(replace all in between <> with your appropriate iformation)

public class DbConn {
private static DbConn database = new DbConn();
// for PostgreSQL
// private String jdbc = &quot;org.postgresql.Driver&quot;;
// private String URL=&quot;jdbc:postgresql:<databasename>&quot;;
// private String login=&quot;<postgres login name>&quot;;
// private String passwd=&quot;<postgres password>&quot;;
// for Oracle
private String jdbc = &quot;oracle.jdbc.driver.OracleDriver&quot;;
private String URL=&quot;jdbc:eek:racle:thin:mad:<servername>:1521:<oracle sid>&quot;;
private String login=&quot;<your oracle login>&quot;;
private String passwd=&quot;<your oracle password>&quot;;

public static Connection con;

private DbConn() {
try {
Class.forName(jdbc);
con = DriverManager.getConnection(URL, login, passwd);
} catch (SQLException e) {
System.out.println(&quot;SQL exception bij creatie DbConn&quot; + e);
} catch (ClassNotFoundException e) {
System.out.println(&quot;class not found bij creatie DbConn&quot; + e);
}
}
public static DbConn getDbConn() {
return database;
}
}

And download the oracle driver !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top