on 2011 Aug 31 5:48 AM
Hello,
I would connect a java application via the JDBC driver jconn3.jar to my database SQL Anywhere v12. Unfortunatly, I discovered that the method named getParameterMetaData returns null.
PreparedStatement pstmt = con.prepareStatement(MY_QUERY); ParameterMetaData paramMetaData = pstmt.getParameterMetaData();
paramMetaData -> null
The JDBC driver named jconn3.jar is it valid ? Is there a workaround?
Thank you for your answer.
Gabriel
Request clarification before answering.
Thanks for all your answers. I reorganized my project. Thus, I don't need anymore a JDBC 4.0 driver to connect myself to a SQL Anywhere database. I have asked the Sybase support about the JDBC drivers and here is their answer:
I confirm you that jconn3.jar from jConnect 6.0.5 is a Type 4 JDBC driver.
The JDBC specification identifies four types of JDBC drivers, from the Type 1 "JDBC-ODBC bridge" to the Type 4 "pure Java" driver. SQL Anywhere includes JDBC 3.0 and 4.0 drivers, which are Type 2 JDBC drivers, and also supports the jConnect driver for pure Java applications, which is a Type 4 JDBC driver.
JDBC applications http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.sqlanywhere.12.0.1/dbprogramming/...
The Java component of the SQL Anywhere JDBC 4.0 driver is included in the sajdbc4.jar file ( Type 2 JDBC drivers) installed into the Java subdirectory of your SQL Anywhere installation.
jconn3.jar (Type 4 JDBC driver) is located in the classes subdirectory of your jConnect 6.0.5 installation
In conclusion, there is no JDBC driver for SQL Anywhere which support the paramMetaData.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm not a JDBC expert, but I know we typically recommend the SQL Anywhere JDBC driver over the JConnect driver I believe you are using. I'm not sure if the SQL Anywhere JDBC driver specifically implements the ParamaterMetaData call you are trying to use, but it is likely worth a try. See "SQL Anywhere JDBC Driver" in the documentation, for example:
http://dcx.sybase.com/index.html#1201/en/dbprogramming/jdbc-odbc-bridge-jdbc.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for the answer.
I run the sample database named demo.db:
C:\\Users\\Public\\Documents\\SQL Anywhere 12\\Samples\\demo.db
I executed the Upgrade Database Wizard. Despite the wizard told me that the jconnect support is already installed in my database, I finished the upgrade. It still not works. Then, I executed the query you have mentionned in the tool named "Interactive SQL". And sadly, I'm still not able to get a ParameterMetaData.
Here is the java code I run:
DriverManager.registerDriver((Driver)Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance());
con = DriverManager.getConnection("jdbc:sybase:Tds:10.23.75.23:2638", "DBA", "sql");
PreparedStatement pstmt = con.prepareStatement("SELECT ID, GivenName, Surname FROM Customers");
ParameterMetaData paramMetaData = pstmt.getParameterMetaData();
if (paramMetaData == null)
{
System.out.println("ERROR: db vendor does NOT support ParameterMetaData");
}
else
{
System.out.println("SUCCEED: ParameterMetaData is supported");
}
You may try on the same sample database with this command:
java -cp .;jconn3.jar JDBCConnect jconnect > output.log
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I agree; it seems that this object returns null in this use-case from my experiments as well.
It should be noted that the ParameterMetaData call is not mandatory or standardized for JDBC 3.0 implementations (See: http://books.google.com/books?id=a8W8fKQYiogC&lpg=PA192&ots=ojZLBy70CM&pg=PA185#v=onepage&q&f=false ), hence the structure of the code samples you have seen elsewhere.
Have you installed the jConnect Metadata system objects on your v12 database yet?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
52 | |
6 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.