on 07-16-2014 9:49 AM
Hello,
When I try to use the connect statement in Java like this:
//connect to database | |||
query = "CONNECT TO 'TOPADMINSA9' DATABASE 'ARCUS' USER 'dba' IDENTIFIED BY 'stef'"; | |||
//query = "CONNECT TO '" + config.getDatabase() + "' DATABASE '" + databaseName + "' USER '" + config.getUser() + "' IDENTIFIED BY '" + config.getPassword() + "'"; | |||
logger.info(query); | |||
statement.executeQuery(query); |
I get this error:
16-07-14 10:47:52 [ERROR] TechLogger - -> com.sybase.jdbc3.jdbc.SybSQLException: ASA Error -131: Syntax error near 'CONNECT' on line 1
But when I execute the same command in my SQL Anywhere Interactive SQL the query works fine.
Any idea what I'm doing wrong?
CONNECT is a DBISQL specific command, not a general database statement. To connect using JDBC you use the getConnection() method. You can find an example in the SQL Anywhere documentation here:
http://dcx.sybase.com/index.html#sa160/en/dbprogramming/connecting-establishing-jdbc.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.