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

JDBC using "connect database XXXX" syntax

1 view
Skip to first unread message

jeffbuser

unread,
Aug 15, 2008, 12:57:46 AM8/15/08
to
I have a SQL Anywhere server configured with multiple
databases started in in a single database server engine.
I'm trying to switch a JDBC call dynamically between
databases. I'm getting an ASA Error -131: Syntax error near
'connect'. I've validated that it's valid syntax for ISQL,
but not sure what translation occurs when processed via JDBC

As an example:

Connection connection = getASAConnection("localhost",
"2638", "DBA", "SQL");
try {
Statement selectStatement = connection.createStatement();
selectStatement.executeQuery(
connection.nativeSQL("connect database SUPPORT") );
} catch (Exception e) {
e.printStackTrace();
}

getting the following stacktrace:

com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -131:
Syntax error near 'connect' on line 1
at
com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2796)
at
com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2126)
at
com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at
com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at
com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at
com.sybase.jdbc2.jdbc.SybStatement.queryLoop(SybStatement.java:1578)
at
com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:156
3)
at
com.sybase.jdbc2.jdbc.SybStatement.executeQuery(SybStatement.java:418
)


Any help or insight to this problem is greatly appreciated.

Jeff Buser
Northrop Grumman Mission Systems
jeffre...@ngc.com

jeffbuser

unread,
Aug 15, 2008, 8:39:47 AM8/15/08
to
Forgot version info.

SQL Anywhere: 9.0.2.3182
JDK: 1.5_10

Bruce Hay

unread,
Aug 15, 2008, 8:56:11 AM8/15/08
to
CONNECT is a DBISQL command, not a statement recognized by the server. You
should create a new connection for the database that you wish to access.
Depending on what you're trying to achieve, you can close the previous
connection before switching to a different database, or maintain multiple
connections and pass the appropriate Connection object into the code you
wish to share.

SQL Anywhere Developer Community:
http://www.sybase.com/developer/library/sql-anywhere-techcorner
SQL Anywhere Blog Center: http://www.sybase.com/sqlanyblogs

<Jeff Buser> wrote in message news:48a57913.21a...@sybase.com...

0 new messages