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
"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.
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).]
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.
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
subject: I need know how to connect Oracle through JSP Programe