/** * Get sql driver from the given connection. * @param conn * @return */ public static String sqlGetDriver(java.sql.Connection conn) { String driver = null; try { driver = conn.getMetaData().getDriverName(); } catch (java.sql.SQLException ex) { Ts.printErr(ex); } return driver; } /** * * @param conn * @return <tt>true</tt> if the sql driver is MySql */ public static boolean sqlIsMySql(java.sql.Connection conn) { return (Ts.stringContains(Ts.sqlGetDriver(conn), "mysql")) ? true : false; } public static boolean sqlIsOracle(java.sql.Connection conn) { return (Ts.stringContains(Ts.sqlGetDriver(conn), "oracle")) ? true : false; } public static java.sql.Connection sqlStatementToConnection(java.sql.Statement stat) { java.sql.Connection conn = null; try { conn = stat.getConnection(); } catch (java.sql.SQLException ex) { Ts.printErr(ex); } return conn; } public static void printErr(java.sql.SQLException ex) { System.out.println("SQL State: " + ex.getSQLState()); System.out.println("Error Code: " + ex.getErrorCode()); Ts.printErr((java.lang.Exception) ex); } public static void printErr(java.lang.Exception ex) { ex.printStackTrace(); System.exit(-1); }