This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes I need know how to connect Oracle through JSP Programe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "I need know how to connect Oracle through JSP Programe" Watch "I need know how to connect Oracle through JSP Programe" New topic
Author

I need know how to connect Oracle through JSP Programe

Venki
Greenhorn

Joined: Jun 09, 2001
Posts: 2
Hi all,
I am working as a programmer in Promen Technologies. I am currently involved in a project which needs Oracle as a backend and JSP to connect. How to code in JSP to connect the Oracle table.
I wrote coding like this
Class.forName("Oracle.jdbc.odbc.OracleOdbcDriver");
con = DriverManager.getConnection("jdbc dbc:test","scott","tiger");
Is that right or wrong. Please lead me into correct coding.
With Regards,
Dinagar.V
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"dinagar",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.
Thanks.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Bjarki Holm
Author
Ranch Hand

Joined: May 25, 2001
Posts: 65
This seems to be correct. However, I recommand using the Oracle JDBC drivers, instead of the ODBC-JDBC bridge as you are currently doing, as that gives much better performance. These drivers can be downloaded from the Oracle Technology Network (http://otn.oracle.com) in a file called classes12.zip. This archive must be present in the runtime class path of the application.
The Oracle JDBC drivers come with two types of drivers: OCI or Thin. More information on each of these is provided at http://technet.oracle.com/docs/products/oracle8i/doc_library/817_doc/ java.817/a83724/overvw2.htm#1000908.
Using the Thin driver, you could get a connection as shown here:
<code>
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc racle:thin:@dbhost:1521:SID";
String user = "scott";
String password = "tiger";
Connection conn = DriverManager.getConnection(url,user,password);
</code>

using the URL of the database host and the Oracle SID instead of <code>dbhost</code> and <code>SID</code>, respectively.
Cheers,
------------------
Bjarki Holm
Author of Professional Java Data
[This message has been edited by Bjarki Holm (edited June 12, 2001).]


Bjarki Holm
Jason Kilgrow
Ranch Hand

Joined: May 21, 2001
Posts: 47
You should probably use a bean in your jsp. Use the bean to access your database. This is Model 1 architecture.
Yes. You CAN access the database directly from your jsp, but it's standard practice to use a bean instead.
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Originally posted by Jason Kilgrow:
You should probably use a bean in your jsp. Use the bean to access your database. This is Model 1 architecture.
Yes. You CAN access the database directly from your jsp, but it's standard practice to use a bean instead.

Even more specifically, you could have a bean in application scope which does all the database setup, but from which you can request a connection object. Sounds kinda like a connection pool doesn't it? Not technically maybe, but same principle.
Jason Menard
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I need know how to connect Oracle through JSP Programe
 
Similar Threads
Can any one help me how can i connect oracle9i with odbc
How can I display CLOB & BLOB data in a JSP?
Connecting JSP to Oracle
Host String in jdbc url
JDBC