This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
Ranch Hand
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!