Skip to Main Content

Java Database Connectivity (JDBC)

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!

JDBC connection from ASP page

843859Oct 18 2005 — edited Oct 18 2005
I am trying to write ASP code (vbscript) that uses ADO to create a database connection using a JDBC driver. I am not sure if this is possible. I have written a small java program which has successfully used the AS400 driver, but I cannot get the ASP page to work. This is the error I keep getting:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I have put the jt400.jar (the AS400 driver file from IBM) file in my CLASSPATH environment variable (Win XP), but the ASP code cannot seem to find the driver. I think it may be a problem with the CLASSPATH since the java code only works when I run it including the -classpath variable. My code is below. Has anyone done this before or know why it is not working? Also, the reason I am attempting this is for performance, since the ODBC AS400 driver is not that fast.

ASP Code: (does not work)

<%

ConnectionString = "DRIVER=com.ibm.as400.access.AS400JDBCDriver;URL={jdbc:as400://SERVER/LIBRARY/USERNAME?user=xxxxxx&password=xxxxxx}"

set con = Server.CreateObject("ADODB.Connection")
con.open(ConnectionString)

mySQL="SELECT * FROM SLSPHY01"
set rstemp=con.execute(mySQL)

DO UNTIL rstemp.eof

subject = rstemp.Fields(0)
response.write subject & ""

rstemp.movenext

LOOP

rstemp.close
set rstemp=nothing
con.close
set con=nothing

%>

Java Code: (works)

import java.sql.*;

public class JdbcExample1 {

public static void main(String args[]) {
Connection con = null;

try {
Class.forName("com.ibm.as400.access.AS400JDBCDriver").newInstance();
con = DriverManager.getConnection("jdbc:as400://SERVER/LIBRARY", "username", "password");


if(!con.isClosed())
System.out.println("Successfully connected to server...");

} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 15 2005
Added on Oct 18 2005
1 comment
551 views