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

connecting to sybase with JDBC drivers

21 views
Skip to first unread message

David Gunzburger

unread,
Aug 24, 2005, 8:59:03 AM8/24/05
to
I have a Java application that connects to SQL Anywhere 9.0.2.3044
database.

I've tried 3 different database drivers to connect to the database,
JConnect (5.5,6.0), iAnywhere JDBC, and sun jdbc odbc.

Both the Jconnect and sun jdbc drivers run correctly. But, since the
database contains Unicode (UTF-8) data, the sun jdbc driver does not
correctly disply the data.

This leaves me with the option of using JConnect or iAnywhere JDBC
driver. From what I've read, everybody tends to recommend the iAnywhere
driver for many reasons (up to 4x performance sounds very nice). I
cannot get the iAnywhere drivers to work correctly though.

Looking at the logs, it seems to be failing with executing prepared
statements. Is there a known issue or limitation concerning prepared
statements?

I'm connecting to the database with the following connection string:

Class.forName("ianywhere.ml.jdbcodbc.IDriver");
con = DriverManager.getConnection("jdbc:odbc:dsn=sybaseDB");

Thanks,
-Dave

Greg Fenton

unread,
Aug 24, 2005, 11:15:17 PM8/24/05
to
David Gunzburger wrote:
>
> Looking at the logs, it seems to be failing with executing prepared
> statements. Is there a known issue or limitation concerning prepared
> statements?
>

Can you show us the code and the stack trace associated with this failure?

greg.fenton
--
Greg Fenton
Consultant, Solution Services, iAnywhere Solutions
--------
Visit the iAnywhere Solutions Developer Community
Whitepapers, TechDocs, Downloads
http://www.ianywhere.com/developer/

David Gunzburger

unread,
Aug 25, 2005, 10:06:49 AM8/25/05
to
The Apache stdout log shows:
> java.sql.SQLException: Not implemented
> at ianywhere.ml.jdbcodbc.IStatement.executeBatch(IStatement.java:164)
> at WebSurvey.DataStore.DataManager.writeAnswer(DataManager.java:100)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
> at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
> at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> at java.lang.Thread.run(Unknown Source)

The java code looks similar to what follows:
//--------------
sql = "INSERT INTO xxx (a,b,c) VALUES (?,?,?)"
con.setAutoCommit(false);
PreparedStatement stmt = con.prepareStatement(sql);

stmt.setString(1,value);
stmt.setInt(2,value);
stmt.setInt(3,value);

int [] Counts = stmt.executeBatch(); //Line 100 in writeAnswer()
//---------------

Hope this maybe can shed some light. Also, just to give a bit more
info, we setup the database to start up as a service when the computer
starts up.

thanks,
-dave

Greg Fenton

unread,
Aug 26, 2005, 12:51:38 AM8/26/05
to
David Gunzburger wrote:
> The Apache stdout log shows:
>
>> java.sql.SQLException: Not implemented
>> at ianywhere.ml.jdbcodbc.IStatement.executeBatch(IStatement.java:164)
>> at WebSurvey.DataStore.DataManager.writeAnswer(DataManager.java:100)


Hmmm....well, I cannot duplicate the problem with a test script I mocked
up. Can you try the following and see if you still get the "not
implemented" exception??

To build, simply run "build.sh".
To run, simply run "run.sh"

If you are testing on MS-Windows, rename the files to ".bat" and replace
"$ASANY9" in the scripts with "%ASANY9%".

build.sh
run.sh
TestBatch.java

David Gunzburger

unread,
Aug 29, 2005, 11:31:24 AM8/29/05
to
Greg,
I went ahead and ran the scripts on a WinXP environment. Here is the output:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\test>build

C:\test>javac -classpath ".;C:\Program Files\Sybase\SQL Anywhere 9/java/jodbc.jar" TestBatch.java

C:\test>run

C:\test>java -cp ".;C:\Program Files\Sybase\SQL Anywhere 9/java/jodbc.jar" TestB
atch "C:\Program Files\Sybase\SQL Anywhere 9/asademo.db"

Successfully connected!


java.sql.SQLException: Not implemented
at ianywhere.ml.jdbcodbc.IStatement.executeBatch(IStatement.java:164)

at TestBatch.main(TestBatch.java:63)

URL is [jdbc:odbc:driver=Adaptive Server Anywhere 9.0;uid=DBA;pwd=SQL;dbf=C:\Pro
gram Files\Sybase\SQL Anywhere 9/asademo.db]

C:\test>

Looks like I'm getting a similar error message. Let me know if you need additional information.
Thanks,
-Dave


Greg Fenton wrote:
> David Gunzburger wrote:
>
>> The Apache stdout log shows:
>>
>>> java.sql.SQLException: Not implemented
>>> at
>>> ianywhere.ml.jdbcodbc.IStatement.executeBatch(IStatement.java:164)
>>> at WebSurvey.DataStore.DataManager.writeAnswer(DataManager.java:100)
>
>
>
> Hmmm....well, I cannot duplicate the problem with a test script I mocked
> up. Can you try the following and see if you still get the "not
> implemented" exception??
>
> To build, simply run "build.sh".
> To run, simply run "run.sh"
>
> If you are testing on MS-Windows, rename the files to ".bat" and replace
> "$ASANY9" in the scripts with "%ASANY9%".
>
> greg.fenton
>
>

> ------------------------------------------------------------------------
>
> javac -classpath ".;$ASANY9/java/jodbc.jar" TestBatch.java
>
>
> ------------------------------------------------------------------------
>
> java -cp ".;$ASANY9/java/jodbc.jar" TestBatch $ASANY9/asademo.db

Greg Fenton

unread,
Aug 29, 2005, 11:41:16 AM8/29/05
to
David Gunzburger wrote:
>
> Successfully connected!
> java.sql.SQLException: Not implemented
> at
> ianywhere.ml.jdbcodbc.IStatement.executeBatch(IStatement.java:164)
> at TestBatch.main(TestBatch.java:63)
>

Can you try a newer EBF? I'm running 9.0.2.3137.

From the README of 3137, I see:

============(Build #3119 - Engineering Case #387869)================

When executing a batch using the PreparedStatement object, it is proper
practice to use the PreparedStatement.executeUpdate() method to execute
the batch and retrieve the single update count associated with it.
However, applications sometimes (incorrectly) use the
preparedStatement.executeBatch() method instead. The iAnywhere JDBC
driver has now been modified to support the
preparedStatement.executeBatch() method in this manner.


Hope this helps,

David Gunzburger

unread,
Aug 30, 2005, 11:26:55 AM8/30/05
to
Thanks! Upgrading to a newer EBF appeared to fix the problem.

Would you recommend using EBF 3137 or 3169? I downloaded the 3169 EBF a couple
weeks ago, but it no longer on the Sybase website for download. This is for a
Windows x86 machine.

Thanks again,
-Dave

Greg Fenton

unread,
Aug 30, 2005, 11:31:55 AM8/30/05
to
David Gunzburger wrote:
> Would you recommend using EBF 3137 or 3169? I downloaded the 3169 EBF a
> couple weeks ago, but it no longer on the Sybase website for download.
> This is for a Windows x86 machine.
>

3169 has been pulled, so I certainly would not suggest using it if
you've got it. I've been using 3137 for quite some time and have not
had any issues with it myself. There is a new EBF coming down the pipe
to replace 3169, but there is not ETA for it.

0 new messages