Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

I need know how to connect Oracle through JSP Programe  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Author
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!