Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC DB Connections etc

 
Will Myers
Ranch Hand
Posts: 392
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One of the advantages of using Hibernate, JPA, etc is that it insulates you from having to worry about the types returned from the queries, do you cover the differences in database implementations of the various objects? For example Oracle seems to roll their own types (Timestamps, etc) instead of using the java.sql versions.
 
A.J. Côté
Ranch Hand
Posts: 417
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am pretty sure the jdbc driver specific to a database engine maps the types of that database engine to java types. In fact, hibernate delegates most of these tasks to the jdbc driver I think...

Here is a link to an online book:

http://www.marcobehler.com/make-it-so-java-db-connections-and-transactions/

The author of the book will be in this javaranch forum this week:

http://www.coderanch.com/t/656510/JDBC/databases/Marco-Behler
 
Will Myers
Ranch Hand
Posts: 392
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I mean is that a result set returned from Oracle for example has the dates as oracle.sql.TIMESTAMP instead of java.sql.Timestamp as you would expect, it's probably just Oracle who do this sort of thing but was wondering if other databases do a similar thing?
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle has the Java TIMESTAMP class to support the functionalities of its TIMESTAMP datatype which aren't supported by JDBC (such as conversions between timezones according to their database - not Java - definitions, which might be useful if the database is accessed by applications written in various languages).

It is possible to use java.sql.Timestamp with Oracle JDBC driver (eg. ResultSet.getTimestamp() is declared to return java.sql.Timestamp, so it is guaranteed it will return the Java version, not Oracle version). But if you need the extended functionalities, the driver gives you a way to access them.

Which JDBC method returns oracle.sql.TIMESTAMP, by the way?
 
Marco Behler
Author
Ranch Hand
Posts: 43
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did that question get answered?

Conversion of timestamps is nothing we talk about in the book really. it is all about connections & tx , as you can see from the toc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic