Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Jconnect to ASA 7.0

27 views
Skip to first unread message

Tom_Hocomb

unread,
Feb 22, 2002, 5:01:25 PM2/22/02
to
I am attempting to connect from a Solaris Box to a networked NT box
that houses a ASA 7.0 database. We are using Jconnect 5.0 and the
package seems to be installed correctly, but I could be wrong. I
should say that I am writing a java program to attempt to connect to
the NT box. Here are some specifics:

java version 1.2.2
jdk version 1.2.2_06

Jconnect version 5.0

Solaris Version 5.7

Adaptive Server Anywhere version 7.0

My program is as follows:
// This is the JDBC Example from module 3, page 3-14.

import java.util.*;
import java.sql.*;
import java.io.*;
import java.net.URL;
import com.sybase.jdbc2.jdbc.SybDriver;


public class JDBCExample {

public static void main (String args[]) {

if (args.length < 1) {
System.err.println ("Usage:");
System.err.println (" java JDBCExample <db server hostname>");
System.exit (1);
}
String serverName = args[0];
Properties props = new Properties();
props.put("user","dba");
props.put("password","sql");
try {
// Create the instance of the Msql Driver
try
{
SybDriver sybDriver = (SybDriver)Class.forName
("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
// sybDriver.setVersion
(com.sybase.jdbc2.jdbc.SybDriver.VERSION_LATEST);
DriverManager.registerDriver(sybDriver);
// Class.forName("com.sybase.jdbcx.SybDriver");
}
catch (ClassNotFoundException e)
{
System.out.println("Invalid Use of Class.forName");
{
System.out.println("Invalid Use of Class.forName");
System.out.println(e.getMessage());
}
catch (InstantiationException e)
{
System.out.println("Invalid Use of Class.forName");
System.out.println(e.getMessage());
}
catch (IllegalAccessException e)
{
System.out.println("Invalid Use of Class.forName");
System.out.println(e.getMessage());
}

// Create the "url"

//String url = "jdbc:sybase:Tds://" + serverName +
":49158/servername=rquotedev";
String url = "jdbc:sybase:Tds://" + serverName + ":2638";
System.out.println(url);

// Use the DriverManager to get a Connection
Connection mSQLcon = DriverManager.getConnection (url);

System.out.println("HERE 1");
// Use the Connection to create a Statement object
/*
Statement stmt = mSQLcon.createStatement ();

// Execute a query using the Statement and return a ResultSet
ResultSet rs = stmt.executeQuery
("SELECT * FROM Customer ORDER BY cust_name");

// Print the results, row by row
while (rs.next()) {
System.out.println ("");
System.out.println ("Customer: " + rs.getString(2));
System.out.println ("Id: " + rs.getString(1));
}
*/
} catch (SQLException e) {
System.out.println("HERE");
e.printStackTrace();
}
}
}


Error Message is
fpd2sun:/home/th04808>java JDBCExample 170.22.72.71
jdbc:sybase:Tds://170.22.72.71:2638
HERE
java.sql.SQLException: JZ003: Incorrect URL format. URL:
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:64)
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:487)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:328)
at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(Compiled Code)
at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:195)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:174)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:126)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:179)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:159)
at JDBCExample.main(JDBCExample.java:55)

Any help would be greatly appreciated. Thanks in advance.
Tom Holcomb

Paul Cotter

unread,
Feb 23, 2002, 12:45:54 PM2/23/02
to
I believe the format is tds:host:port and not tds://host:port

You may have to supply additional servername parameter in the form...

tds://host:port?servername=xxxxx

...if you are running more than one database server on the NT. I thing there
is another parameter if you are running more than one database on the
database server but I do not know what it is

Paul

<Tom_Hocomb> wrote in message
news:818B848CC85928D40078FABA85256B68.0078FAD785256B68@webforums...

Matthew Chestnut

unread,
Feb 24, 2002, 2:35:04 PM2/24/02
to
I form my URL like:

jdbc:sybase:Tds:localhost:2638/mydb?SERVICENAME=demodb

So, change:

jdbc:sybase:Tds://170.22.72.71:2638

to:

jdbc:sybase:Tds:170.22.72.71:2638

Tom_Holcomb

unread,
Feb 25, 2002, 11:59:23 AM2/25/02
to
Thank you very much, I should have seen that change, but a different set of
eyes always helps. I now have encountered another error, I was wondering
if this error is more on the NT side or a UNIX issue. If you have some
time any assistance is appreciated.

Error Message:
java.sql.SQLException: JZ006: Caught IOException:
java.net.ConnectException: Connection refused


at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:64)
at
com.sybase.jdbc2.jdbc.ErrorMessage.raiseError(ErrorMessage.java:487)
at

com.sybase.jdbc2.jdbc.ErrorMessage.raiseErrorCheckDead(ErrorMessage.java:723)
at com.sybase.jdbc2.tds.Tds.handleIOE(Tds.java:3071)
at com.sybase.jdbc2.tds.Tds.login(Tds.java:394)


at com.sybase.jdbc2.jdbc.SybConnection.tryLogin(Compiled Code)
at
com.sybase.jdbc2.jdbc.SybConnection.regularConnect(SybConnection.java:195)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:174)
at
com.sybase.jdbc2.jdbc.SybConnection.<init>(SybConnection.java:126)
at com.sybase.jdbc2.jdbc.SybDriver.connect(SybDriver.java:179)
at java.sql.DriverManager.getConnection(Compiled Code)

at java.sql.DriverManager.getConnection(DriverManager.java:106)
at JDBCExample.main(JDBCExample.java:56)

Thanks,
Tom Holcomb

Tom_Holcomb

unread,
Feb 25, 2002, 4:06:49 PM2/25/02
to
Thanks You So Much, for ending my 2 weeks of FRUSTRATION. If I can ever be
of help for anything please let me know.

Thanks Again,
Tom Holcomb
tom.h...@carefirst.com

Matthew Chestnut

unread,
Feb 25, 2002, 1:17:12 PM2/25/02
to
The "connection refused" error sounds like it doesn't like your user
name/password combo. This Sybase jConnect PDF is very handy (if you
don't already have it) http://sybooks.sybase.com/jcg0550e.html
0 new messages