Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

mySQL INTEGER == LONG in Java and ....???

 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a program that creates a table as follows:

Notice that this is using MySQL and that Cups and Entry are INTEGERS and Customer is a VARCHAR. But when I run the following snippet from another program:

It doesn't print that Entry is of type int. I get an error
stating that my driver
org.gjt.mm.mysql.jdbc2.NotImplemented
What are the equivalent conversions from MySQL to Java? I am able to retreive the data and work with it, but when it tries to find its class equivalent, I get an error.
Thanks for your attention to my problem.
Brian
 
Phil Hanna
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DatabaseMetaData interface provides a getTypeInfo() method. This returns a result set that includes every type name recognized by the connection and the equivalent java.sql.Types constant that it maps to. With a switch statement, you can equate this to the appropriate java.sql.Types name.


------------------
Phil Hanna
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Brian Snyder
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Phil for your response. My question was, however, why doesn't getColumnClassName work correctly??
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!