Package net.risesoft.api.utils.jdbc
Class JdbcUtils
- java.lang.Object
-
- net.risesoft.api.utils.jdbc.JdbcUtils
-
public final class JdbcUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringALI_ORACLEstatic StringALI_ORACLE_DRIVERstatic StringDB2static StringDB2_DRIVERstatic StringDERBYstatic StringDMstatic StringDM_DRIVERstatic StringH2static StringH2_DRIVERstatic StringHBASEstatic StringHIVEstatic StringHSQLstatic StringJTDSstatic StringKINGBASEstatic StringKINGBASE_DRIVERstatic StringLOG4JDBCLog4JDBCstatic StringLOG4JDBC_DRIVERstatic StringMARIADBstatic StringMARIADB_DRIVERstatic StringMOCKstatic StringMYSQLstatic StringMYSQL_DRIVERstatic StringODPSstatic StringORACLEstatic StringORACLE_DRIVERstatic StringPOSTGRESQLstatic StringPOSTGRESQL_DRIVERstatic StringSQL_SERVERstatic StringSQL_SERVER_DRIVERstatic StringSYBASE
-
Constructor Summary
Constructors Constructor Description JdbcUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(Closeable x)static voidclose(Connection x)static voidclose(ResultSet x)static voidclose(Statement x)static DrivercreateDriver(ClassLoader classLoader, String driverClassName)static DrivercreateDriver(String driverClassName)static voidexecute(Connection conn, String sql, List<Object> parameters)static voidexecute(DataSource dataSource, String sql, Object... parameters)static voidexecute(DataSource dataSource, String sql, List<Object> parameters)static List<Map<String,Object>>executeQuery(Connection conn, String sql, List<Object> parameters)static List<Map<String,Object>>executeQuery(DataSource dataSource, String sql, Object... parameters)static List<Map<String,Object>>executeQuery(DataSource dataSource, String sql, List<Object> parameters)static intexecuteUpdate(Connection conn, String sql, List<Object> parameters)static intexecuteUpdate(DataSource dataSource, String sql, Object... parameters)static intexecuteUpdate(DataSource dataSource, String sql, List<Object> parameters)static StringgetDbType(String rawUrl, String driverClassName)static StringgetDriverClassName(String rawUrl)static StringgetTypeName(int sqlType)static voidinsertToTable(Connection conn, String tableName, Map<String,Object> data)static voidinsertToTable(DataSource dataSource, String tableName, Map<String,Object> data)static StringmakeInsertToTableSql(String tableName, Collection<String> names)static voidprintResultSet(ResultSet rs)static voidprintResultSet(ResultSet rs, PrintStream out)static voidprintResultSet(ResultSet rs, PrintStream out, boolean printHeader, String seperator)
-
-
-
Field Detail
-
JTDS
public static final String JTDS
- See Also:
- Constant Field Values
-
MOCK
public static final String MOCK
- See Also:
- Constant Field Values
-
HSQL
public static final String HSQL
- See Also:
- Constant Field Values
-
DB2
public static final String DB2
- See Also:
- Constant Field Values
-
DB2_DRIVER
public static final String DB2_DRIVER
- See Also:
- Constant Field Values
-
POSTGRESQL
public static final String POSTGRESQL
- See Also:
- Constant Field Values
-
POSTGRESQL_DRIVER
public static final String POSTGRESQL_DRIVER
- See Also:
- Constant Field Values
-
SYBASE
public static final String SYBASE
- See Also:
- Constant Field Values
-
SQL_SERVER
public static final String SQL_SERVER
- See Also:
- Constant Field Values
-
SQL_SERVER_DRIVER
public static final String SQL_SERVER_DRIVER
- See Also:
- Constant Field Values
-
ORACLE
public static final String ORACLE
- See Also:
- Constant Field Values
-
ORACLE_DRIVER
public static final String ORACLE_DRIVER
- See Also:
- Constant Field Values
-
ALI_ORACLE
public static final String ALI_ORACLE
- See Also:
- Constant Field Values
-
ALI_ORACLE_DRIVER
public static final String ALI_ORACLE_DRIVER
- See Also:
- Constant Field Values
-
MYSQL
public static final String MYSQL
- See Also:
- Constant Field Values
-
MYSQL_DRIVER
public static final String MYSQL_DRIVER
- See Also:
- Constant Field Values
-
MARIADB
public static final String MARIADB
- See Also:
- Constant Field Values
-
MARIADB_DRIVER
public static final String MARIADB_DRIVER
- See Also:
- Constant Field Values
-
DERBY
public static final String DERBY
- See Also:
- Constant Field Values
-
HBASE
public static final String HBASE
- See Also:
- Constant Field Values
-
HIVE
public static final String HIVE
- See Also:
- Constant Field Values
-
H2
public static final String H2
- See Also:
- Constant Field Values
-
H2_DRIVER
public static final String H2_DRIVER
- See Also:
- Constant Field Values
-
DM
public static final String DM
- See Also:
- Constant Field Values
-
DM_DRIVER
public static final String DM_DRIVER
- See Also:
- Constant Field Values
-
KINGBASE
public static final String KINGBASE
- See Also:
- Constant Field Values
-
KINGBASE_DRIVER
public static final String KINGBASE_DRIVER
- See Also:
- Constant Field Values
-
ODPS
public static final String ODPS
- See Also:
- Constant Field Values
-
LOG4JDBC
public static final String LOG4JDBC
Log4JDBC- See Also:
- Constant Field Values
-
LOG4JDBC_DRIVER
public static final String LOG4JDBC_DRIVER
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public static void close(Connection x)
-
close
public static void close(Statement x)
-
close
public static void close(ResultSet x)
-
close
public static void close(Closeable x)
-
printResultSet
public static void printResultSet(ResultSet rs) throws SQLException
- Throws:
SQLException
-
printResultSet
public static void printResultSet(ResultSet rs, PrintStream out) throws SQLException
- Throws:
SQLException
-
printResultSet
public static void printResultSet(ResultSet rs, PrintStream out, boolean printHeader, String seperator) throws SQLException
- Throws:
SQLException
-
getTypeName
public static String getTypeName(int sqlType)
-
getDriverClassName
public static String getDriverClassName(String rawUrl) throws SQLException
- Throws:
SQLException
-
createDriver
public static Driver createDriver(String driverClassName) throws SQLException
- Throws:
SQLException
-
createDriver
public static Driver createDriver(ClassLoader classLoader, String driverClassName) throws SQLException
- Throws:
SQLException
-
executeUpdate
public static int executeUpdate(DataSource dataSource, String sql, Object... parameters) throws SQLException
- Throws:
SQLException
-
executeUpdate
public static int executeUpdate(DataSource dataSource, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
executeUpdate
public static int executeUpdate(Connection conn, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
execute
public static void execute(DataSource dataSource, String sql, Object... parameters) throws SQLException
- Throws:
SQLException
-
execute
public static void execute(DataSource dataSource, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
execute
public static void execute(Connection conn, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
executeQuery
public static List<Map<String,Object>> executeQuery(DataSource dataSource, String sql, Object... parameters) throws SQLException
- Throws:
SQLException
-
executeQuery
public static List<Map<String,Object>> executeQuery(DataSource dataSource, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
executeQuery
public static List<Map<String,Object>> executeQuery(Connection conn, String sql, List<Object> parameters) throws SQLException
- Throws:
SQLException
-
insertToTable
public static void insertToTable(DataSource dataSource, String tableName, Map<String,Object> data) throws SQLException
- Throws:
SQLException
-
insertToTable
public static void insertToTable(Connection conn, String tableName, Map<String,Object> data) throws SQLException
- Throws:
SQLException
-
makeInsertToTableSql
public static String makeInsertToTableSql(String tableName, Collection<String> names)
-
-