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

asked 31 Aug '11, 04:48

Gabriel's gravatar image

Gabriel
31114
accept rate: 50%

edited 15 Mar '13, 21:35

Mark%20Culp's gravatar image

Mark Culp
24.9k10139297


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/sa9b6fb370-66fc-400e-9334-208ea33eecab.html

  • 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.

permanent link

answered 19 Sep '11, 04:42

Gabriel's gravatar image

Gabriel
31114
accept rate: 50%

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

permanent link

answered 08 Sep '11, 13:38

Ian%20McHardy's gravatar image

Ian McHardy
3.4k23557
accept rate: 40%

Have you installed the jConnect Metadata system objects on your v12 database yet?

Try: ALTER DATABASE UPGRADE JCONNECT ON

permanent link

answered 31 Aug '11, 17:19

Jeff%20Albion's gravatar image

Jeff Albion
10.8k171175
accept rate: 25%

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

permanent link

answered 01 Sep '11, 08:53

Gabriel's gravatar image

Gabriel
31114
accept rate: 50%

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.

(07 Sep '11, 15:25) Jeff Albion
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×86
×39
×23
×20

question asked: 31 Aug '11, 04:48

question was seen: 5,673 times

last updated: 15 Mar '13, 21:35