Sybase Business Intelligence Solutions - Database Management, Data Warehousing Software, Mobile Enterprise Applications and Messaging
Sybase Brand Color Bar
delete

Search for    in all of Sybase.com
view all search results right arrow
  blank
 
 
 
 
 
 
 
 
 
 
Support > Technical Documents > Document Types > FAQ > jConnect for JDBC Frequently Asked Questions

jConnect for JDBC Frequently Asked Questions

Index of Sections
 
RSS Feed
 
 
 


Section 2: JDBC Programming
  1. What class should I instantiate in order to use the Sybase JDBC driver? 
  2. What URL should I use when making a connection? 
  3. Where can I find java samples using jdbc? 


Section 3: Browser, Platform, and VM Version Specifics 
  1. I compile my applet using javac but when I run my applet via netscape, it fails. Why? 
  2. Netscape on Sun Solaris 
  3. How can I run jConnect for JDBC on Macintosh? 
  4. Cannot connect to a remote machine using the IP address. 
  5. What are the programming differences for JDK1.0.2 and JDK1.1? 
  6. Bignum or BigDecimal, which do I use? 


Section 4: SQL Server Version
  1. Does jConnect for JDBC work with Microsoft SQL Server? 
  2. * How can I connect to SQL Anywhere? 
  3. Does setAutoCommit() work with SQL Anywhere? 
  4. Can I connect to a 4.9.2 dataserver? 


Section 5: jConnect for JDBC Qualities
  1. Why use jConnect for JDBC? 
  2. What do you do better than your JDBC-industry peers? 
  3. Difference with web.sql? 


Section 6: HTTP Gateway
  1. What does the message "HTTPServer ... Address already in use" mean? 
  2. Gateway connection refused: HTTP/1.0 502 Bad Gateway|Restart Connection 
  3. When do I need a JDBC Gateway? 
  4. I tried changing the port number and now no applets will run. 


Section 7: Statement Types
  1. Why do sql commands containing strings with curly braces sometimes not work? 
  2. Multiple statements and hanging applications 
  3. Why do "compute" statements cause the program to hang? 
  4. CallableStatement: Why is setDate not implemented? 
  5. CallableStatement and PreparedStatement: Why do input parameters not work with SQL Anywhere? 


Section 8: Running IsqlApp Sample
  1. What are the command line options of IsqlApp? 
  2. What is "ribo:3767"? 
  3. I'm unable to see all the text in the edit fields of the Isql applet. 


Section 9: Miscellaneous
  1. Is there any plan to include multi-language support in jConnect for JDBC? 


Section 2: JDBC Programming
What class should I instantiate in order to use the Sybase JDBC driver?
This depends on the version of jConnect you are intending to use. For jConnect 4.x, the class you would instantiate is com.sybase.jdbc.SybDriver. For example,Class.forName("com.sybase.jdbc.SybDriver").newInstance(); If you are using jConnect 5.x, the class you would instantiate is com.sybase.jdbc2.jdbc.SybDriver. For example, Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();

What URL should I use when making a connection? 
The URL should be: jdbc:sybase:Tds:<hostname>:<port#>For example, to connect to a SQL Server on alder listening on port 6689, I would use the following commands:Connection _con;

String url = "jdbc:sybase:Tds:alder:6689";

_con = DriverManager.getConnection(url, "sa", ""); You can specify a database using the following syntax:jdbc:sybase:Tds:<hostname>:<port#>/<database>


Where can I find java samples using jdbc?
Click Isql.java for a sample Java applet
Click IsqlApp.java for a sample Java application


Section 3: Browser, Platform, and VM Version Specifics

I compile my applet using javac but when I run my applet via Netscape on Unix, it fails. Why? 

To run Java applets, Netscape Navigator needs to load Java class files from a file called java_30 (Netscape 3.0) or java_301 (Netscape 3.0.1). This file is included in the Netscape distribution, but must be moved to one of these directories:The current directory
/usr/local/netscape/java/classes
/usr/local/lib/netscape
~/.netscapeJava applets will not run with the old .car files or old .zip files. You must replace your old .car or .zip files with the new java_30 file.

Netscape on Sun Solaris 
JDBC on Sun Solaris requires Netscape 3.0 or higher in order for the Java JDBC Applets to work.

How can I run jConnect for JDBC on Macintosh? 
Some customers have reported successfully running jConnect for JDBC on the Macintosh and have shared the following instructions: 
  • Create CodeWarrior project, "Java Application" 
  • add "Isql.java" 
  • add "classes.zip", "javasql.zip", sybjdbc.zip" 
  • Change applet to frame 
    • change getParamter(...) to null 
    • comment out showStatus(...) 
  • Run it! 

Cannot connect to a remote machine using the IP address. 
Make sure that the targeted host IP address and name are mapped in /etc/hosts (UNIX), or you need to upgrade to JDK 1.1. There appears to be a bug in the JDK1.0.2 VM that does not allow a connection to complete if the actual machine name of the targeted host is not mapped. Here's an example of the problem:If workstation 'xyz' is at IP address 130.214.90.27, you should be able to make a connection to the dataserver on xyz (port 3767) with either URL: 
jdbc:sybase:Tds:xyz:3767orjdbc:sybase:Tds:130.214.90.27:3767
But if xyz's address were not known to your machine by name (the standard system function gethostbyname("xyz") fails), then trying to use the second URL will fail with JDK 1.0.2, but succeed with JDK 1.1.You can test whether your machine knows a remote machine's IP address by name by using the 'ping' command: 
% ping xyz
If the ping returns something like 'xyz is alive' then you are OK with 1.0.2, but if it returns 'xyz: unknown host' - then you either have to modify your machine so it knows that host (add an entry to /etc/hosts on unix) or you need to upgrade to JDK 1.1.

What are the programming differences for JDK1.0.2 and JDK1.1?Programming Requirements for JDK1.0.2 
  • The CLASSPATH environment variable should include the following path: 
    • Unix Platforms: $JDBC_HOME/syb102.zipWindows 95/Windows NT:%JDBC_HOME%\syb102.zip 
  • Use the following includes: 
    • import jdbc.sql.*; import jdbc.math.*;import jdbc.sybase.utils.Debug; // Sybase internal debugging classimport jdbc.sybase.jdbc.*;import java.util.*; 
  • Use the following driver: 
    • Class.forName("jdbc.sybase.jdbc.SybDriver"); 
Programming Requirements for JDK1. 
  • The CLASSPATH environment variable should include the following path: 
    • Unix Platforms: $JDBC_HOME/sybjdbc.zipWindows 95/Windows NT:%JDBC_HOME%\sybjdbc.zip 
  • Use the following includes: 
    • import java.io.*; import java.sql.*;import com.sybase.utils.Debug;import java.util.*; 
  • Use the following driver: 
    • Class.forName("com.sybase.jdbc.SybDriver"); 

Bignum or BigDecimal, which do I use?

Bignum has been replaced by BigInteger and BigDecimal and is no longer supported by JDBC. JDK1.1 requires the use of jdbc.math.BigDecimal or jdbc.math.BigInteger for NUMERIC or DECIMAL SQL types. Please note the BigDecimal difference between the native (JDK1.1) and the 1.0.2/downloadable implementations:JDK1.1 native: 

BigDecimal has unlimited precision.
JDK1.0.2/downloadable: 
BigDecimal has reduced precision, using 8 bytes to store NUMERIC or DECIMAL SQL fields, which yeilds approximately 18 digits of precision.If a field is selected that exceeds the 8 byte limitation, an ArithmeticException:Overflow will be raised.


Section 4: SQL Server Version

Does jConnect for JDBC work with Microsoft SQL Server?

No, jConnect doesn't support pre-5.0 TDS (the protocol between client and server). Microsoft SQL Server is based on TDS 4.2, therefore, jConnect does not work with MS SQL Server currently. We may provide MS support in the future. But no date is set or committed at this point.

In the meantime, you can connect to MS SQL Server via Sybase OmniCONNECT Gateway. OmniCONNECT is a high performance gateway allowing transparent data access to 25+ non-Sybase databases including MS SQL, Oracle, Informix, and DB2, etc.


How can I connect to SQL Anywhere?

You need to run the SQL Anywhere Open Server Gateway dbos50 which is included in the SQL Anywhere distribution. The free download version from the Sybase website includes the Open Server Gateway.

Does setAutoCommit() work with SQL Anywhere? 

To get setAutoCommit() to work with SQL Anywhere, you must first CREATE the database using SQL Anywhere 5.5.01. If the database was created using an older version, perform an UNLOAD/RELOAD of the database first.

downloads.sybase.com (contains the maintenance releases).

To change the chained mode, use usual TSQL syntax or SQL Anywhere syntax: set option chained='off|on'


Can I connect to a 4.9.2 dataserver?

JDBC uses TDS 5.0. The 4.9.X SQL-Servers are using TDS 4.6, which is not compatible with TDS 5.0.

You have to use a System 10 or higher SQL-Server with JDBC. That was one of the compatibility/simplicity tradeoffs we made very early on in design.



Section 5: jConnect for JDBC Qualities

Why use jConnect? 

jConnect is designed specifically for today's thin client Java applets and applications. It requires zero client administration and maintenance costs. It provides scalable and high performance database access for business critical applications in a multi-tier environment. At the same time, jConnect is JDBC standards compliant and is compatible with other JDBC drivers. It is the right choice for organization deploying network-based business applications.

What do you do better than your JDBC-industry peers? 
Performance: We expect significant performance gain over most competing JDBC solutions because jConnect provides direct access to Sybase SQL Server via the native Tabular Data Stream (TDS) protocol. Most other JDBC solutions today must rely on either vendor provided drivers such as Sybase CT-Lib/DB-Lib or slower performance ODBC drivers.With the advent of NATIVE Java compilers and JIT compilers that produce execution speeds in Java at or near speeds of compiled C, the JDBC interface may well become THE fastest way to access Sybase servers - including CT-Lib/DB-Lib native applications. This is possible because Sybase has been able to completely re-architect the layers necessary to read/write TDS for Java. Through multi-threading and OO features of Java like exception handling, several layers of software that have to be there for CT-Lib and DB-Lib were cut out. Furthermore, since jConnect is generating and reading pure TDS, even in the 3-tier solution space, our middle tier gateway is MUCH simpler and faster. It is simply a router - doing 2-way forwarding of data without the need to understand or re-format it.
Ease of Use: jConnect can be network-resident and does not require the installation of ODBC drivers or CT-Lib/DB-Lib on the client machine. Because all software is installed and configured on the network server, upgrades can be downloaded dynamically to the client, thus easing software administration, support and distribution nightmare. Other JDBC solutions may require complex configuration on the server as well as the client because they are based on ODBC.
Lower Costs: Because jConnect provides just-in-time deployment, it dramatically reduces the software administration and support costs. It enables organizations to deploy new Internet business applications in "web time," thus gaining competitive advantage.

Difference with web.sql? 
web.sql was designed to provide dynamic web content by embedding Perl-based business logic in the HTML pages. Through Sybase Open Client Library (CT-LIB), web.sql accesses complete family of Sybase products and generates web pages dynamically. web.sql resides with the Web Server, and so all processing is done on the server-side. Through the HTTP protocol, web.sql sends web pages to the client browser.
In the case of jConnect, it is based on 100% Java. It allows business logic partitioned in both client and server. Instead of HTTP protocol, jConnect allows direct communication between the client and the server via remote procedure calls (RPCs) or directly to the databases via Tabular Data Stream (TDS). jConnect is ideal for a new class of thin client Java-based business applications.


Section 6: HTTP Gateway

What does the message "HTTPServer ... Address already in use" mean? 

When I attempt to start the gateway, ie httpd.sh, it gives me this error:HTTPServer: IOException: getRequest() Address already in useSome process is already running on the machine which is listening to port 8000 - perhaps another web server? Either stop that other process, or change the www.conf/www.dos files to pick a different port number. You would also have to change the .java sources to give that new port # in the 'proxy' property which is passed into DriverManager.getConnection().Another option is: go into the $JDBC_HOME/www.template file and change the port # there. If you change the port#, you'll also need to modify the $JDBC_HOME/sample/gateway.html file to change the 'proxy' param from localhost:8000 to localhost:whatever new port you pickAfter killing the currently running httpd and trying to restart it, I am getting: HTTPServer: IOException: getRequest() Address already in use. The 'ps' command doesn't show any http job left over, and 'netstat' doesn't show anything with socket 8000 being used. As for ps, on Solaris try/usr/ucb/ps -auxww | grep uk.co.demonAs for netstat on Solaris not showing socket 8000, you will find that netstat displays "sqlexec" instead of port 8000 and "infmx" instead of 8001 (at least on some of our Solaris systems. See also /etc/services)If you kill the Cascade server and restart it right away, it might indeed exit with the "Address already in use" message, because the socket might still be in state TIME_WAIT. Wait a few minutes and try again. On Unix systems, you can wait until the port number is no longer listed by netstat.

Gateway connection refused: HTTP/1.0 502 Bad Gateway|Restart Connection 
Are you sure you've got the right hostname/port # entered for connecting to you SQL Server? This should be the 'query' entry from your $SYBASE/interfaces or %SYBASE%\ini\sql.ini file.If you re-start your http server with the 'verbose' system property set, then the http server will give a bunch of additional info on what is causing this connection failure.% java -Dverbose=1 uk.co.demon.cascade.http.HTTPServer www.conf

When do I need a JDBC Gateway?
When your database is on a different server than your web server.

I tried changing the port number and now no applets will run. 
If you change the port# in www.template you also need to change the port# in sample/gateway.html. They need to match.


Section 7: Statement Types

Why do sql commands containing strings with curly braces sometimes not work? 

Example:create table mytable (value varchar(10))
insert into mytable values("{}") NOTE: Download the most recent version of jConnect for JDBC. This problem was corrected in the 31 Jan 97 release.

Multiple statements and hanging applications 
If I create two statements and put them into a loop, the program stops responding during the second iteration of the outer loop.Example:
Statement s1 = connection.createStatement();
Statement s2 = connection.createStatement();

ResultSet rs1 = s1.executeQuery("select column1 from table1");
while (rs1.next()) {

Object obj = rs.getObject(1);
String objname = obj != null ? obj.toString() : "null";
// The program stops here on the second iteration of the outer loop
ResultSet rs2 = 
s2.executeQuery("select column2 from table2 where object = '" 
+ objname + "'");

while (rs2.next()) {
// do more stuff here
}
}
 

This problem was corrected in the 31 Jan 97 release. 

Why do "compute" statements cause the program to hang? 
The application hangs when a query contains a computed row, e.g. : select name from sysobjects where type="S" compute count(name) An early design decision was made not to support 'Compute rows' in JDBC. We need to make this much more clear in our documentation. The 'compute' clause is a Sybase extension which we haven't found many people using. You could achieve the same thing in a 'standard' way by executing: select name from sysobjects where type="S"
select count(name) from sysobjects where type="S" The whole idea of 'compute' rows does not map cleanly to the way JDBC sets up Statements and ResultSets. We could try to force a mapping that made each alternating RowData/ComputeData set look like separate ResultSets, but the normal count information would not always be available at the right times. Adding this to the driver would make it bigger without adding alot of functionality.

CallableStatement: Why is setDate not implemented? 
Sybase does not really have a 'Date' datatype, nor do we have a Time type. The Timestamp is the closest we have, and all the versions of getTimestamp/setTimestamp should work. It was decided to just leave that function unimplemented. There are a number of methods which throw this "unimplemented" RuntimeException, they are documented in the release notes.

CallableStatement and PreparedStatement: Why do input parameters not work with SQL Anywhere? 
Input parameters for PreparedStatement and CallableStatement will not work with SQL Anywhere versions below 5.5.00 (which is the first SQL Anywhere Professional release).


Section 8: Running IsqlApp Sample

What are the command line options of IsqlApp? 

If you have a machine named 'hostname' on your network, and 'hostname' is running a SQL-Server that listens on port 1234 (the 'query' entry in the interfaces file under your server), and this SQL Server has a user 'guest' with password 'guestpwd', then:
% java IsqlApp -S jdbc:sybase:Tds:hostname:1234 -U guest -P guestpwd
would get you connected.

Run 'java IsqlApp -help' to get a full description of the command-line.


What is "ribo:3767"?
I get the error message

java.io.IOException: Connection failed to 'ribo:3767'

when I run "java IsqlApp". What is "ribo:3767" and where is this being picked up from?

The problem is that the database to connect to is not specified. "ribo:3767" happens to be a SQL-Database running on a workstation within the Sybase firewall. You need to use command-line arguments to specify your server.

You can do one of two things:

1. Modify the line

static String _server = "jdbc:sybase:Tds:ribo:3767";

in sample/IsqlApp.java. Change "ribo" to the name of your database host machine and "3767" to the port number of the database server. Then recompile IsqlApp.

2. If you have a machine named 'hostname' on your network, and 'hostname' is running a SQL-Server that listens on port 1234 (the 'query' entry in the interfaces file under your server), and this SQL Server has a user 'guest' with password 'guestpwd', then:

% java IsqlApp -S jdbc:sybase:Tds:hostname:1234 -U guest -P guestpwd
would get you connected.

Run 'java IsqlApp -help' to get a full description of the command-line.


I'm unable to see all the text in the edit fields of the Isql applet.
You can modify the applet diminsions:
  • Edit $JDBC_HOME/sample/gateway.html 
  • Change line 7 from width=750 height=400> to width=750 height=650>  
You can experiment with different height settings.


Section 9: Miscellaneous

Is there any plan to include multi-language support in jConnect for JDBC?

We don't plan to provide I18N internationalization & localization support in the release 1.0 of jConnect for JDBC. This feature will be available in future releases of the product. 



 

DOCUMENT ATTRIBUTES
Last Revised: Jan 14, 2000
Product: jConnect for JDBC
Technical Topics: Java, Connectivity
  
Business or Technical: Technical
Content Id: 1009876
Infotype: FAQ - Technical
 
 
 

© Copyright 2014, Sybase Inc. - v 7.6 Home / Contact Us / Help / Jobs / Legal / Privacy / Code of Ethics