Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Error connection to Oracle from JSP

843838Jun 22 2007 — edited Jun 24 2007
I am trying to connect to oracle from jsp

this is the class which I have created to test. I have atken this class from oracle documentation




package user;

import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;

public class JdbcTest {
public static void getName () {
// Create DataSource and connect to the local database
try
{
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:@//MOMJI:1521/TESTDB");
ods.setUser("system");
ods.setPassword("testdb");
Connection conn = ods.getConnection();

// Query the employee names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT name FROM ani");
// Print the name out
while (rset.next ())
System.out.println (rset.getString (1));

//close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
System.out.print("ERROR"+e.getMessage());
}

}
}


Now when I create an instance using useBean in jsp file I get an error that
java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource

I dont understand what to do. If you have any othet way of accessing the DD then plz tell.
I have set the classpath for ojdbc14.jar and orai18n.jar.

Please reply

Comments

794117
Setting the CLASSPATH environment variable doesn't help web applications.

To include the driver in the classpath for the web app, put the jars in the WEB-INF/lib directory of your web application.

ie - put ojdbc14.jar into your WEB-INF/lib directory.

BTW - this code doesn't look like a JSP to me. And a JSP shouldn't be making database connection itself anyway.
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 22 2007
Added on Jun 22 2007
1 comment
92 views