com.alibaba.druid.util
Class JdbcUtils

java.lang.Object
  extended by com.alibaba.druid.util.JdbcUtils

public final class JdbcUtils
extends Object

Author:
wenshao

Field Summary
static String ALI_ORACLE
           
static String DB2
           
static String DERBY
           
static String H2
           
static String HBASE
           
static String HIVE
           
static String HSQL
           
static String JTDS
           
static String MOCK
           
static String MYSQL
           
static String ORACLE
           
static String POSTGRESQL
           
static String SQL_SERVER
           
static String SYBASE
           
 
Constructor Summary
JdbcUtils()
           
 
Method Summary
static void close(Closeable x)
           
static void close(Connection x)
           
static void close(ResultSet x)
           
static void close(Statement x)
           
static Driver createDriver(ClassLoader classLoader, String driverClassName)
           
static Driver createDriver(String driverClassName)
           
static void execute(Connection conn, String sql, List<Object> parameters)
           
static void execute(DataSource dataSource, String sql, List<Object> parameters)
           
static void execute(DataSource dataSource, String sql, 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, List<Object> parameters)
           
static List<Map<String,Object>> executeQuery(DataSource dataSource, String sql, Object... parameters)
           
static int executeUpdate(Connection conn, String sql, List<Object> parameters)
           
static int executeUpdate(DataSource dataSource, String sql, List<Object> parameters)
           
static int executeUpdate(DataSource dataSource, String sql, Object... parameters)
           
static String getDbType(String rawUrl, String driverClassName)
           
static String getDriverClassName(String rawUrl)
           
static String getTypeName(int sqlType)
           
static void insertToTable(Connection conn, String tableName, Map<String,Object> data)
           
static void insertToTable(DataSource dataSource, String tableName, Map<String,Object> data)
           
static Class<?> loadDriverClass(String className)
           
static String makeInsertToTableSql(String tableName, Collection<String> names)
           
static void printResultSet(ResultSet rs)
           
static void printResultSet(ResultSet rs, PrintStream out)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

POSTGRESQL

public static final String POSTGRESQL
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

ORACLE

public static final String ORACLE
See Also:
Constant Field Values

ALI_ORACLE

public static final String ALI_ORACLE
See Also:
Constant Field Values

MYSQL

public static final String MYSQL
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
Constructor Detail

JdbcUtils

public JdbcUtils()
Method Detail

close

public static final void close(Connection x)

close

public static final void close(Statement x)

close

public static final void close(ResultSet x)

close

public static final void close(Closeable x)

printResultSet

public static final void printResultSet(ResultSet rs)
                                 throws SQLException
Throws:
SQLException

printResultSet

public static final void printResultSet(ResultSet rs,
                                        PrintStream out)
                                 throws SQLException
Throws:
SQLException

getTypeName

public static String getTypeName(int sqlType)

getDriverClassName

public static String getDriverClassName(String rawUrl)
                                 throws SQLException
Throws:
SQLException

getDbType

public static String getDbType(String rawUrl,
                               String driverClassName)

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

loadDriverClass

public static Class<?> loadDriverClass(String className)

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)


Copyright © 2012 Alibaba Group. All Rights Reserved.