Prev: jsp/servlet target
Next: How to get an include-path of jni.h that is able to be differenton different platforms.
From: New Java 456 on 28 Jan 2010 15:12 I'm sure someone has this. Need to map data types from all the various dbs. I can reverse it out of the Postgresql doc but does anyone at least have a better doc; for I'd have to look up each sqltype definition from the vendor jdbc classes. http://www.ispirer.com/wiki/sqlways/postgresql/data-types We need Java code, not a tool. Maybe this mapping exists inside some ETL open source tool already? Thanks in advance for any pointers or suggestions, TimJowers
From: John B. Matthews on 28 Jan 2010 15:53 In article <3f71f772-538f-45ad-9e25-833b78bfe30f(a)21g2000yqj.googlegroups.com>, New Java 456 <newjava456(a)gmail.com> wrote: > I'm sure someone has this. Need to map data types from all the > various dbs. I can reverse it out of the Postgresql doc but does > anyone at least have a better doc; for I'd have to look up each > sqltype definition from the vendor jdbc classes. > http://www.ispirer.com/wiki/sqlways/postgresql/data-types We need > Java code, not a tool. Maybe this mapping exists inside some ETL open > source tool already? Thanks in advance for any pointers or > suggestions, Typically, the JDBC driver encapsulates the mapping: <http://java.sun.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html> "There is considerable variation among the different SQL types supported by the different databases." See also, "Notes and Lamentations": <http://java.sun.com/javase/6/docs/technotes/guides/jdbc/getstart/mapping.html#table1> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
From: Arne Vajhøj on 28 Jan 2010 20:51 On 28-01-2010 15:12, New Java 456 wrote: > I'm sure someone has this. Need to map data types from all the various > dbs. I can reverse it out of the Postgresql doc but does anyone at > least have a better doc; for I'd have to look up each sqltype > definition from the vendor jdbc classes. http://www.ispirer.com/wiki/sqlways/postgresql/data-types > We need Java code, not a tool. Maybe this mapping exists inside some > ETL open source tool already? If you have the database running then you can so like this: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; public class GetDBTypes { public static void test(String driver, String conurl, String un, String pw) throws ClassNotFoundException, SQLException { Class.forName(driver); Connection con = DriverManager.getConnection(conurl, un, pw); ResultSet rs = con.getMetaData().getTypeInfo(); while(rs.next()) { System.out.println(rs.getString("TYPE_NAME") + " -> " + rs.getString("DATA_TYPE")); } rs.close(); con.close(); } public static void main(String[] args) throws Exception { test("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/Test", "root", ""); } } Arne PS: The integer written out is java.sql.Types !
From: Roedy Green on 29 Jan 2010 01:23 On Thu, 28 Jan 2010 12:12:13 -0800 (PST), New Java 456 <newjava456(a)gmail.com> wrote, quoted or indirectly quoted someone who said : >I'm sure someone has this. Need to map data types from all the various >dbs. I can reverse it out of the Postgresql doc but does anyone at >least have a better doc; for I'd have to look up each sqltype >definition from the vendor jdbc classes. http://www.ispirer.com/wiki/sqlways/postgresql/data-types >We need Java code, not a tool. Maybe this mapping exists inside some >ETL open source tool already? >Thanks in advance for any pointers or suggestions, >TimJowers Since you are going to access via JDBC, you need to know the JDBC types see http://mindprod.com/jgloss/jdbc.html The catch is you will use the JBDC types and Java types in your program, but the PostGre types in your the SQL you use to initially define the database. Perhaps by experiment you can create a chart combining all three. Just make a table with one of everything and see how it maps in Java. I made my own PostGre table, but it is not as good as the one you already found. see http://mindprod.com/jgloss/postgresql.html If you do this, please pass on your findings so I can post a complete HTML table with six columns PostGre, Bounds, JDBC, Java, Notes. -- Roedy Green Canadian Mind Products http://mindprod.com Computers are useless. They can only give you answers. ~ Pablo Picasso (born: 1881-10-25 died: 1973-04-08 at age: 91)
From: Lew on 29 Jan 2010 08:37
Roedy Green wrote: > The catch is you will use the JBDC types and Java types in your > program, but the PostGre [sic] types in your the SQL you use to initially > define the database. It's "Postgres" or "PostreSQL", not "Postgre". -- Lew |