hi.

I am trying to evaluate your driver for Sybase, Jconnect, but i have
found some problems.

When i execute a class who use Jconnect with JDB, i have an error who
blocks the application.

I have copied the message generated by the JDB. I would want to know
what is the problem.

The code for Essai.java is:

// Extract version info from the driver, try to connect to the sample
// pubs2 database outside the Sybase corporate firewall.
import java.io.*;
import java.sql.*;
import com.sybase.utils.Debug;
import java.util.*;

public class Essai
{
public static void main(String args[])
{
String url = "jdbc:sybase:Tds:199.199.9.19:11030";
String query = "SELECT * FROM currency";

try {
Class.forName("com.sybase.jdbc.SybDriver");
Driver driver = DriverManager.getDriver(url);
int major = driver.getMajorVersion();
int minor = driver.getMinorVersion();
System.out.println("Using JDBC driver version " + major +
"." + minor);

Properties props = new Properties();
props.put("user", "pipo");
props.put("password", "pipo");
DriverPropertyInfo dpi[] = driver.getPropertyInfo(url,
props);
// get the version string
for (int i = 0; i < dpi.length; i++) {
if (dpi[i].name.equals("VERSIONSTRING")) {
System.out.println(dpi[i].value);
break;
}
}
System.out.println("Your CLASSPATH, Java environment, and "
+
"jdbcConnect drivers are properly installed\n\ttrying to
" +
"connect to the Sybase sample dataserver --\n\t...");

// attempt to connect
Connection con = DriverManager.getConnection(url, props);
System.out.println("Connected successfully");

// Get the DatabaseMetaData object and display
// some information about the connection
DatabaseMetaData dma = con.getMetaData ();

System.out.println("\nConnected to " + dma.getURL());
System.out.println("Driver " + dma.getDriverName());
System.out.println("Version " +
dma.getDriverVersion());
System.out.println("");


// Create a Statement object so we can submit
// SQL statements to the driver
Statement stmt = con.createStatement ();

// Submit a query, creating a ResultSet object
ResultSet rs = stmt.executeQuery (query);

// Display all columns and rows from the result set
dispResultSet (rs);

// Close the result set
rs.close();

// Close the statement
stmt.close();

con.close();
}

catch (SQLException sqe) {
String sqlstate = sqe.getSQLState();
String message = sqe.toString();
System.out.println("Unexpected exception: " + sqlstate);
if (sqlstate.equals("JZ0I4"))
{
if (message.indexOf("502") > 0)
{
System.out.println("\nThis error usually indicates
that " +
"your HTTP gateway was unable to reach the
database " +
"that you specified.\n\n One source of this
problem may " +
"be that you are running the httpd/gateway under
a " +
"JDK1.0.2 level VM. 1.0.2 has a bug where if
you try " +
"to connect to an IP Address which your
operation system " +
"does not have a 'name' for (gethostbyname
fails?) " +
"then it cannot open a socket to it. This
problem is " +
"fixed in JDK1.1 - if you kill your httpd
gateway and " +
"restart it under JDK1.1 this problem may be
resolved.");
}
else if (message.indexOf("Connection failed to") > 0)
{
System.out.println("\nThis error often indicates
that " +
"the database you are trying to connect to
is not up. " +
"Try to verify (use a non-jdbc tool) that "
+ url +
" is running.");
}
}
sqe.printStackTrace();
System.exit(1);
}
catch (Throwable e)
{
System.out.println("Unexpected exception : " +
e.toString());
if (e instanceof ClassNotFoundException)
{
System.out.println("\nThis error usually indicates that
" +
"your Java CLASSPATH environment has not been " +
"set properly.");
}
if (e instanceof NoClassDefFoundError)
{
System.out.println("\nThis error may indicate there " +
"is a version incompatibility among the classes " +
"listed in your CLASSPATH.");
}
e.printStackTrace();
System.exit(1);
}
System.exit(0);
}

private static void dispResultSet (ResultSet rs)
throws SQLException
{
int i;

// Get the ResultSetMetaData. This will be used for
// the column headings

ResultSetMetaData rsmd = rs.getMetaData ();

// Get the number of columns in the result set

int numCols = rsmd.getColumnCount ();

// Display column headings

for (i=1; i<=numCols; i++) {
if (i > 1) System.out.print(",");
System.out.print(rsmd.getColumnLabel(i));
}
System.out.println("");

// Display data, fetching until end of the result set

boolean more = rs.next ();
while (more) {

// Loop through each column, getting the
// column data and displaying

for (i=1; i<=numCols; i++) {
if (i > 1) System.out.print(",");
System.out.print(rs.getString(i));
}
System.out.println("");

// Fetch the next result set row

more = rs.next ();
}
}


}

And the output for JDB:



C:\jdk1.1.3\projects>jdb Essai
Initializing jdb...
0xb246e0:class(Essai)
> run
run Essai
running ...
main[1] Using JDBC driver version 2.1
jConnect (TM) for JDBC(TM)/2.1/Evaluation/JDK11/Wed Jul 16 9:19:13 1997
(Unlicenced)
Your CLASSPATH, Java environment, and jdbcConnect drivers are properly
installed

trying to connect to the Sybase sample dataserver --
...
Sybase jConnect ([Internal debugger error: invalid type code:
1126180948]

Fatal exception: java.lang.NullPointerException
java.lang.NullPointerException
at sun.tools.debug.AgentIn.run(AgentIn.java:80)
at java.lang.Thread.run(Thread.java:474)


What i have to do????

Thanks for all.

Ismael osiris4@worldnet.fr