Hai this might help u. <%@ page import="java.sql.*" %> <%! Connection con;Statement stmt;ResultSet rs,rsMaterial;String state,Fadd;%> Class.forName("oracle.jdbc.driver.OracleDriver"); con = DriverManager.getConnection("jdbc racle:thin:scott/tiger@ipaddresswhere oracle is installed:1521:cle8i"); stmt = con.createStatement(); Bye Jayanthi
Kareem Gad
Ranch Hand
Joined: Aug 06, 2001
Posts: 89
posted
0
I have a comment though on all this, It's better to right your database connection statements and all in a bean and just use the useBean directive in jsp and call the connect method from there .. its alot more tidier that actually writing the code raw in the jsp. It beats the basic reason why we have jsp, to separate the presentation logic from the business logic. C ya
------------------ KaReEm
<b><i>KaReEm</i><br /><ul type="square"><li>SCJP-Free Range Web Developer <br /></ul></b>
Dave Soto
Ranch Hand
Joined: Sep 15, 2001
Posts: 55
posted
0
Well, how about EJB for that matter? He's obviously just beginning with the whole J2EE thing, so he probably needs to take it one step at a time...
Terence Doyle
Ranch Hand
Joined: May 30, 2001
Posts: 328
posted
0
HI, I'm having trouble too. I posted this doubt in the JDBC forum but there's no answer yet. Perhaps you could tell me whats wrong with this line of code as it produces SQLExceptions (its the line 24 mentioned in the errors below.)
notes: The Driver manager and class path are fine. The user and password are "DEMO" The database is called "MYDB" The errors I get are: Exception in thread "main" java.sql.SQLException: Excepci�n Io: The Network Adapter could not establish the connection at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323) at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:263) at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260) at java.sql.DriverManager.getConnection(DriverManager.java:517) at java.sql.DriverManager.getConnection(DriverManager.java:199) at driver_ver.main(driver_ver.java:24)
[This message has been edited by Terence Doyle (edited September 23, 2001).]
Raising Flares debut album 'Ignition' out now
http://www.raisingflares.com
Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Dave Soto
Ranch Hand
Joined: Sep 15, 2001
Posts: 55
posted
0
First, make sure you are loading the driver, like this:
Then, you can try this syntax for making a connection instead:
Third, and most important. That error you are getting can also occur if Oracle is not running, or if the TNSListener is not running.
Terence Doyle
Ranch Hand
Joined: May 30, 2001
Posts: 328
posted
0
Thanks, Yes I suspect my oracle isnt doing its bit. I just downloaded it ( yes I know 277MB is a lot but luckily I have ADSL ) and installed it to be able to stick it on my CV I'll have to get into the nitty gritty next week. For the moment I'm cramming for my Java Cert exam this Friday.....