HP OpenVMS Systemsask the wizard |
The Question is:
Java Question:
I am trying to use the following code to connect to Jturbos jdbc driver for
MS SQL Server. Works fine on Unix,NT,MAC and compiles fine on OpenVMS but I
get Classnotfound error on
Class.forName ("com.ashna.jturbo.driver.Driver");
my CLASSPATH is set fine and my directory structure looks like
(e.g.
DISK$0:[USER.JTURBO4-20.COM.ASHNA.TURBO.DRIVER]
Where I execute JAVA CLASS:
DISK$0:[USER.JTURBO4-20]
Executing command
java "stest"
it seem as though the JM is having problems qualifying the qualified path.
Any Suggestions would be appreciated.
Thanks!
JAVA CODE:
import java.sql.*;
/**
* Test retreiving values back using scrollable updatable resultSet.
*
*/
public class stest
static public void main(String args[])
throws java.lang.ClassNotFoundException, Exception
{
Connection cx = null;
Statement stmt;
ResultSet rs;
try {
Class.forName("com.ashna.jturbo.driver.Driver");
String url = "jdbc:JTurbo://pch329:1433/Product
Catalog/sql70=true";
String user = "xxx";
String password = "xxx";
//DriverManager.setLogStream(System.out);
cx = java.sql.DriverManager.getConnection(url, user, password);
System.out.println("Connected");
stmt = cx.createStatement();
rs = stmt.executeQuery("SELECT * from test;");
System.out.println("Got results:");
while(rs.next()) {
String str = rs.getString(1);
System.out.println(str);
}
}
catch(Exception e) {
System.out.println(e);
}
cx.close();
System.exit(-1);
}
The Answer is :
Here is an example of working with classpaths:
$ java -version
java version "1.2.2-1"
Classic VM (build J2SDK.v.1.2.2-1:07/29/2000-02:00, native threads, jit_122)
$ ty HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println ("Hello Java!");
}
$ javac HelloWorld.java
$ java "HelloWorld
Hello Java!
$ jar -cvf h.jar "HelloWorld.class
added manifest
adding: HelloWorld.class(in = 425) (out= 291)(deflated 31%)
$ del HelloWorld.class.*
$ java "HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
$ java -classpath h.jar "HelloWorld
Hello Java!
$ sh log classpath
%SHOW-S-NOTRAN, no translation for logical name CLASSPATH
$ def/user classpath h.jar
$ java "HelloWorld
Hello Java!
$ sh log java$classpath
%SHOW-S-NOTRAN, no translation for logical name JAVA$CLASSPATH
$ def/user java$classpath h.jar
$ java "HelloWorld
Hello Java!
|