List of usage examples for java.sql DatabaseMetaData getDatabaseProductName
String getDatabaseProductName() throws SQLException;
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC zshen Comment method "isMssql".//w w w .ja v a2 s. c om * * @param connection * @return decide to whether is mssql connection * @throws SQLException */ public static boolean isMssql(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && !connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().equals(DatabaseConstant.ODBC_MSSQL_PRODUCT_NAME)) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcPostgresql". * //from w ww. java2 s .c om * @param connection * @return * @throws SQLException */ public static boolean isOdbcPostgresql(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.POSTGRESQL_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcOracle". * /*from w w w .j a v a 2 s . c o m*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcOracle(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.ODBC_ORACLE_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * //from w w w . java2 s .c o m * DOC qiongli Comment method "isOdbcOracle". * * @param connection * @return * @throws SQLException */ public static boolean isOdbcTeradata(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.ODBC_TERADATA_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC xqliu Comment method "isOdbcIngres". * /*from ww w . j a va2 s. c om*/ * @param connection * @return * @throws SQLException */ public static boolean isOdbcIngres(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.ODBC_DRIVER_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase() .indexOf(DatabaseConstant.INGRES_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.talend.cwm.db.connection.ConnectionUtils.java
/** * DOC hwang Comment method "isMysql"./*from w w w . ja va 2 s .c o m*/ * * @param connection * @return * @throws SQLException */ public static boolean isMysql(java.sql.Connection connection) throws SQLException { @SuppressWarnings("deprecation") DatabaseMetaData connectionMetadata = org.talend.utils.sql.ConnectionUtils .getConnectionMetadata(connection); if (connectionMetadata.getDriverName() != null && connectionMetadata.getDriverName().toLowerCase().startsWith(DatabaseConstant.MYSQL_PRODUCT_NAME) && connectionMetadata.getDatabaseProductName() != null && connectionMetadata .getDatabaseProductName().toLowerCase().indexOf(DatabaseConstant.MYSQL_PRODUCT_NAME) > -1) { return true; } return false; }
From source file:org.openbizview.util.Indh18.java
/** * Leer Datos de paises// ww w .j av a 2 s .co m * @throws NamingException * @throws IOException **/ public void select(int first, int pageSize, String sortField, Object filterValue) throws SQLException, ClassNotFoundException, NamingException { //System.out.println("entre al metodo SELECT"); Context initContext = new InitialContext(); DataSource ds = (DataSource) initContext.lookup(JNDI); con = ds.getConnection(); //Reconoce la base de datos de coneccin para ejecutar el query correspondiente a cada uno DatabaseMetaData databaseMetaData = con.getMetaData(); productName = databaseMetaData.getDatabaseProductName();//Identifica la base de datos de coneccin if (codcia == null) { codcia = " - "; } if (codcia == "") { codcia = " - "; } if (anocal == null) { anocal = ""; } if (semcal == null) { semcal = ""; } String[] veccia = codcia.split("\\ - ", -1); String[] vecsem = semcal.split("\\ - ", -1); //Consulta paginada String query = "SELECT * FROM"; query += "(select query.*, rownum as rn from"; query += "(SELECT A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, TO_CHAR(D.FECINI,'DD/MM/YY') AS FECINI, TO_CHAR(D.FECFIN,'DD/MM/YY') AS FECFIN "; query += " FROM INDH18 A, INDT03 B, TUBDER03A D"; query += " WHERE A.CODCIA = B.CODCIA"; query += " AND A.ANOCAL = D.ANOCAL"; query += " AND A.SEMCAL = D.SEMCAL"; query += " AND TRIM(A.CODCIA) LIKE TRIM('%" + veccia[0] + "%')"; query += " AND TRIM(A.ANOCAL) LIKE TRIM('%" + anocal + "%')"; query += " AND TRIM(A.SEMCAL) LIKE TRIM('%" + vecsem[0] + "%')"; query += " GROUP BY A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, D.FECINI, D.FECFIN"; query += ")query ) "; query += " WHERE ROWNUM <=" + pageSize; query += " AND rn > (" + first + ")"; query += " ORDER BY CODCIA, ANOCAL, SEMCAL " + sortField.replace("z", ""); pstmt = con.prepareStatement(query); //System.out.println(query); r = pstmt.executeQuery(); while (r.next()) { Indh18 select = new Indh18(); select.setZcodcia(r.getString(1)); select.setZanocal(r.getString(2)); select.setZsemcal(r.getString(3)); select.setZtotusd(r.getString(4)); select.setZdesc1(r.getString(5)); select.setZciadesc(r.getString(1) + " - " + r.getString(5)); select.setZsemana(r.getString(3) + " - " + r.getString(6) + " al " + r.getString(7)); //Agrega la lista list.add(select); } //Cierra las conecciones pstmt.close(); con.close(); }
From source file:org.openbizview.util.Instanciasusr.java
/** * Leer registros en la tabla//w w w . j av a 2 s . c o m * @throws NamingException * @throws IOException **/ public void counter(Object filterValue) throws SQLException, NamingException { try { Context initContext = new InitialContext(); DataSource ds = (DataSource) initContext.lookup(JNDI); con = ds.getConnection(); //Reconoce la base de datos de coneccin para ejecutar el query correspondiente a cada uno DatabaseMetaData databaseMetaData = con.getMetaData(); productName = databaseMetaData.getDatabaseProductName();//Identifica la base de datos de coneccin String query = ""; if (instancias == null) { instancias = " - "; } if (instancias == "") { instancias = " - "; } String[] veccodrol = instancias.split("\\ - ", -1); switch (productName) { case "Oracle": query = "SELECT count_instanciasusr('" + ((String) filterValue).toUpperCase() + "','" + veccodrol[0] + "') from dual"; break; case "PostgreSQL": query = "SELECT count_instanciasusr('" + ((String) filterValue).toUpperCase() + "','" + veccodrol[0] + "')"; break; case "Microsoft SQL Server": query = "SELECT DBO.count_instanciasusr('" + ((String) filterValue).toUpperCase() + "','" + veccodrol[0] + "')"; break; } pstmt = con.prepareStatement(query); //System.out.println(query); r = pstmt.executeQuery(); while (r.next()) { rows = r.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } //Cierra las conecciones pstmt.close(); con.close(); r.close(); }
From source file:org.openbizview.util.Indh10.java
/** * Leer Datos de paises// www . j a v a2 s . c om * @throws NamingException * @throws IOException **/ public void select(int first, int pageSize, String sortField, Object filterValue) throws SQLException, ClassNotFoundException, NamingException { //System.out.println("entre al metodo SELECT"); Context initContext = new InitialContext(); DataSource ds = (DataSource) initContext.lookup(JNDI); con = ds.getConnection(); //Reconoce la base de datos de coneccin para ejecutar el query correspondiente a cada uno DatabaseMetaData databaseMetaData = con.getMetaData(); productName = databaseMetaData.getDatabaseProductName();//Identifica la base de datos de coneccin if (codcia == null) { codcia = " - "; } if (codcia == "") { codcia = " - "; } if (anocal == null) { anocal = ""; } if (semcal == null) { semcal = ""; } String[] veccia = codcia.split("\\ - ", -1); String[] vecsem = semcal.split("\\ - ", -1); //Consulta paginada String query = "SELECT * FROM"; query += "(select query.*, rownum as rn from"; query += "(SELECT A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, TO_CHAR(D.FECINI,'DD/MM/YY') AS FECINI, TO_CHAR(D.FECFIN,'DD/MM/YY') AS FECFIN "; query += " FROM Indh10 A, INDT03 B, TUBDER03A D"; query += " WHERE A.CODCIA = B.CODCIA"; query += " AND A.ANOCAL = D.ANOCAL"; query += " AND A.SEMCAL = D.SEMCAL"; query += " AND TRIM(A.CODCIA) LIKE TRIM('%" + veccia[0] + "%')"; query += " AND TRIM(A.ANOCAL) LIKE TRIM('%" + anocal + "%')"; query += " AND TRIM(A.SEMCAL) LIKE TRIM('%" + vecsem[0] + "%')"; query += " GROUP BY A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, D.FECINI, D.FECFIN"; query += ")query ) "; query += " WHERE ROWNUM <=" + pageSize; query += " AND rn > (" + first + ")"; query += " ORDER BY CODCIA, ANOCAL, SEMCAL " + sortField.replace("z", ""); pstmt = con.prepareStatement(query); //System.out.println(query); r = pstmt.executeQuery(); while (r.next()) { Indh10 select = new Indh10(); select.setZcodcia(r.getString(1)); select.setZanocal(r.getString(2)); select.setZsemcal(r.getString(3)); select.setZtotusd(r.getString(4)); select.setZdesc1(r.getString(5)); select.setZciadesc(r.getString(1) + " - " + r.getString(5)); select.setZsemana(r.getString(3) + " - " + r.getString(6) + " al " + r.getString(7)); //Agrega la lista list.add(select); } //Cierra las conecciones pstmt.close(); con.close(); }
From source file:org.openbizview.util.Indh11.java
/** * Leer Datos de paises//from w w w . jav a 2 s. co m * @throws NamingException * @throws IOException **/ public void select(int first, int pageSize, String sortField, Object filterValue) throws SQLException, ClassNotFoundException, NamingException { //System.out.println("entre al metodo SELECT"); Context initContext = new InitialContext(); DataSource ds = (DataSource) initContext.lookup(JNDI); con = ds.getConnection(); //Reconoce la base de datos de coneccin para ejecutar el query correspondiente a cada uno DatabaseMetaData databaseMetaData = con.getMetaData(); productName = databaseMetaData.getDatabaseProductName();//Identifica la base de datos de coneccin if (codcia == null) { codcia = " - "; } if (codcia == "") { codcia = " - "; } if (anocal == null) { anocal = ""; } if (semcal == null) { semcal = ""; } String[] veccia = codcia.split("\\ - ", -1); String[] vecsem = semcal.split("\\ - ", -1); //Consulta paginada String query = "SELECT * FROM"; query += "(select query.*, rownum as rn from"; query += "(SELECT A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, TO_CHAR(D.FECINI,'DD/MM/YY') AS FECINI, TO_CHAR(D.FECFIN,'DD/MM/YY') AS FECFIN "; query += " FROM Indh11 A, INDT03 B, TUBDER03A D"; query += " WHERE A.CODCIA = B.CODCIA"; query += " AND A.ANOCAL = D.ANOCAL"; query += " AND A.SEMCAL = D.SEMCAL"; query += " AND TRIM(A.CODCIA) LIKE TRIM('%" + veccia[0] + "%')"; query += " AND TRIM(A.ANOCAL) LIKE TRIM('%" + anocal + "%')"; query += " AND TRIM(A.SEMCAL) LIKE TRIM('%" + vecsem[0] + "%')"; query += " GROUP BY A.CODCIA, A.ANOCAL, A.SEMCAL, A.totusd, B.DESCIA, D.FECINI, D.FECFIN"; query += ")query ) "; query += " WHERE ROWNUM <=" + pageSize; query += " AND rn > (" + first + ")"; query += " ORDER BY CODCIA, ANOCAL, SEMCAL " + sortField.replace("z", ""); pstmt = con.prepareStatement(query); //System.out.println(query); r = pstmt.executeQuery(); while (r.next()) { Indh11 select = new Indh11(); select.setZcodcia(r.getString(1)); select.setZanocal(r.getString(2)); select.setZsemcal(r.getString(3)); select.setZtotusd(r.getString(4)); select.setZdesc1(r.getString(5)); select.setZciadesc(r.getString(1) + " - " + r.getString(5)); select.setZsemana(r.getString(3) + " - " + r.getString(6) + " al " + r.getString(7)); //Agrega la lista list.add(select); } //Cierra las conecciones pstmt.close(); con.close(); }