JDBC Connection to a schema
Hi, I am trying to connect a schema within a database directly through JDBC with the following Java code. Connection con = DriverManager.getConnection(
"jdbc:monetdb://localhost/testUser", "monetdb", "monetdb"); con.setSchema("schema1");
But this throws the following exception.
Exception in thread "main" java.sql.SQLException: syntax error, unexpected '=' in: "set schema =" at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.executeQuery( MonetConnection.java:2525) at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.processQuery( MonetConnection.java:2273) at nl.cwi.monetdb.jdbc.MonetStatement.internalExecute( MonetStatement.java:497) at nl.cwi.monetdb.jdbc.MonetStatement.execute(MonetStatement.java:338) at nl.cwi.monetdb.jdbc.MonetStatement.executeUpdate( MonetStatement.java:533) at nl.cwi.monetdb.jdbc.MonetConnection.setSchema(MonetConnection.java:1267 ) at batcave.Monet.main(Monet.java:11)
Is it really possible to connect to a specific schema? Or the only option is to query as "schemaName.tableName" ??? Thanks & Regards, Vijayakrishna.P. Mobile : (+91) 9500402305.
The correct SQL syntax should be the following: set schema schema1; I am not familiar with JDBC, but you can try to just execute this query instead of using the setSchema shortcut. Regards, Robin On 14-10-15 08:39, Vijay Krishna wrote:
Hi,
I am trying to connect a schema within a database directly through JDBC with the following Java code.
Connection con = DriverManager.getConnection("jdbc:monetdb://localhost/testUser", "monetdb", "monetdb"); con.setSchema("schema1");
But this throws the following exception.
Exception in thread "main" java.sql.SQLException: syntax error, unexpected '=' in: "set schema =" at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.executeQuery(MonetConnection.java:2525) at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.processQuery(MonetConnection.java:2273) at nl.cwi.monetdb.jdbc.MonetStatement.internalExecute(MonetStatement.java:497) at nl.cwi.monetdb.jdbc.MonetStatement.execute(MonetStatement.java:338) at nl.cwi.monetdb.jdbc.MonetStatement.executeUpdate(MonetStatement.java:533) at nl.cwi.monetdb.jdbc.MonetConnection.setSchema(MonetConnection.java:1267) at batcave.Monet.main(Monet.java:11)
Is it really possible to connect to a specific schema? Or the only option is to query as "schemaName.tableName" ???
Thanks & Regards,
Vijayakrishna.P. Mobile : (+91) 9500402305.
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
Thanks a lot for the info Martin. Have filed a bug as well. Will use the proposed work around till its fixed. Thanks & Regards, Vijayakrishna.P. Mobile : (+91) 9500402305. On Thu, Oct 15, 2015 at 8:21 PM, martin van dinther < martin.van.dinther@monetdbsolutions.com> wrote:
Hi Vijayakrishna,
con.setSchema("schema1"); should work, however it internally creates and sends invalid update statement: set schema = "schema1" to the server. This is incorrect syntax. Would you be so kind to log this issue in bugzilla via: https://www.monetdb.org/bugzilla/enter_bug.cgi?format=guided
As a work around you may execute the statement: set schema "schema1" yourself after the connection is made.
Alternatively you may change the default schema for the user which is used to connect to the server. ALTER USER *"**user_name*" SET SCHEMA *"**schema_name*" See: https://www.monetdb.org/Documentation/SQLreference/Users This way you should automatically get into the right schema for that user and you do not need to set the schema each time from your client application.
Regards, Martin van Dinther
On 14-10-15 08:39, Vijay Krishna wrote:
Hi,
I am trying to connect a schema within a database directly through JDBC with the following Java code.
Connection con = DriverManager.getConnection(
"jdbc:monetdb://localhost/testUser", "monetdb", "monetdb"); con.setSchema("schema1");
But this throws the following exception.
Exception in thread "main" java.sql.SQLException: syntax error, unexpected '=' in: "set schema =" at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.executeQuery( MonetConnection.java:2525) at nl.cwi.monetdb.jdbc.MonetConnection$ResponseList.processQuery( MonetConnection.java:2273) at nl.cwi.monetdb.jdbc.MonetStatement.internalExecute( MonetStatement.java:497) at nl.cwi.monetdb.jdbc.MonetStatement.execute(MonetStatement.java:338) at nl.cwi.monetdb.jdbc.MonetStatement.executeUpdate( MonetStatement.java:533) at nl.cwi.monetdb.jdbc.MonetConnection.setSchema( MonetConnection.java:1267) at batcave.Monet.main(Monet.java:11)
Is it really possible to connect to a specific schema? Or the only option is to query as "schemaName.tableName" ???
Thanks & Regards,
Vijayakrishna.P. Mobile : (+91) 9500402305.
_______________________________________________ users-list mailing listusers-list@monetdb.orghttps://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
participants (3)
-
martin van dinther
-
Robin Cijvat
-
Vijay Krishna