Two Laptop Bag*
The moose likes JSP and the fly likes oracle database and jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "oracle database and jsp" Watch "oracle database and jsp" New topic
Author

oracle database and jsp

nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
help,,, im sori i don't know what category to put my problem with, but all i know is that i put 'oracle.jdbc.driver.OracleDriver' into a jsp page so thats the reason why i put it here on this forum... oh my, im stuck here for a week...
okay,,, so here's my problem.. i don't know how to explain this but here goes...
in my jsp page,,, i wanted to connect to oracle database and access the data inside it... this is what i did in my jsp page...
<%@ page language="java" import="java.io.*, java.util.*, java.lang.reflect.Array, java.sql.*" %>
<%@ page language="java" import=" oracle.jdbc.driver.OracleDriver, oracle.jdbc.driver.OracleResultSet"%>
Connection conn = null; // current db connection

try {
String username="scott";
String password="tiger";
String oracleport="1521";

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection("jdbc racle:thin:@Table:"+oracleport+":"+nene,username,password);
conn.setAutoCommit(false);

GetData();

} catch (SQLException e){

} finally { CloseConnection();
}
*let's just assume that the functions GetData() and CloseConnection() are error free and they correct fully functioning well,
'GetData()' is the function where it gets all the data from the oracle database and put it into an jspVariablearray,
'CloseConnection()' is a function where it closes the database, -->
when i run the page, there is no servlet exception that appear, but when i checked the values from the generated html code, it shows that its values are zero...
my guess in the problem is that it didn't connect from the database because i did a class of this whole code from a java file lets named it Database.java, when i compiled and debug Database.java in the software Sun One and Forte, it had accessed the values from the oracle database, it is just in the jsp page that it didn't accessed the values...
i saw two things that could have been the problem why it didn't connect in the database, 1) from the page import i extracted OracleDriver.class and OracleResultSet.class in its .zip file namely classes12.zip my friend told me that it shouldn't not been extracted from the .zip file but he didn't know why... i don't how to import a .zip file to a page...
2) is that i don't know if
conn = DriverManager.getConnection("jdbc racle:thin:@Table:"+oracleport+":"+nene,username,password);
is the correct method of connecting to the oracle database from a jsp page....
so this is where i need help from you guys..
a) how to import .zip file to a jsp page...
b) is there any other method to connect to an oracle database from a jsp page?
c) is my theory correct? that my problem is the connection of database?
d) did you understand my problem?
thanks in advance guys,,, i know you can do it!


if you have helped me in my questions, whether dumb or hard.. all i could say is...<br />YOU'RE THE MAN/WOMAN!!!
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
oh my what happend im sori about my grammar and with the quote this is what the real code should look like...
conn = DriverManager.getConnection("jdbcracle:thin:@"+user.hostName+":"+oracleport+":"+user.oracleName,username,password);
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
another mistake... sorry...
conn = DriverManager.getConnection("jdbcracle:thin:@Table:"+oracleport+":nene",username,password);
this is what it really should look like for you guys.. sorry...
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Hi,
You can set the classes12.zip in the server classpath.
The url for connecting to a database is jdbc racle:thin:@<machine-name>:<port-no>:<sid>","user","password".
You can confirm if you are using the correct values using forte.Click on the Runtime tab->databases->oracle-> test the values.

The other way of creating connecing to the database is using jdbc datasource wherin you create connection pool in the server.
If you are using Sun one appserver for deploying your application , I guess I can help you if you have any more issues in connecting to the database.
Let me know.
nene batungbakal
Greenhorn

Joined: Apr 24, 2003
Posts: 16
thanks
i checked my connection method using the Sun One IDE, and it works...
i am now using macromedia dreamweaver to create my jsp page and my webserver is resin... but i cannot get my connection to work, this is what my import looks like this:
<%@ page language="java" import=" oracle.jdbc.driver.OracleDriver, oracle.jdbc.driver.OracleResultSet"%>
because i extracted OracleDriver.class and OracleResultSet.class from classes12.zip. is this correct?
[ May 06, 2003: Message edited by: nene batungbakal ]
Amol Desai
Ranch Hand

Joined: Jan 29, 2003
Posts: 82
Hi,
You don't have to extract the classes from the zip file.
You have to set classes12.zip in the resin server classpath.
I guess I could help you if you post the erros messages that you get while connecting to the database
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: oracle database and jsp
 
Similar Threads
doubt having servlet connect to oracle XE database
Cannot open connection issue
Access database from a class file
pls help me deal with jsp--oracle database connection
Database Connection problem.Help Please