Package com.alibaba.druid.util
Class MySqlUtils
- java.lang.Object
-
- com.alibaba.druid.util.MySqlUtils
-
public class MySqlUtils extends Object
-
-
Constructor Summary
Constructors Constructor Description MySqlUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Stringbig5(String hex)static StringbuildKillQuerySql(Connection connection, SQLException error)static XAConnectioncreateXAConnection(Driver driver, Connection physicalConn)static BigDecimaldecimal(BigDecimal value, int precision, int scale)static Stringgbk(String hex)static ClassgetCommunicationsExceptionClass()static StringgetCreateTableScript(Connection conn)static StringgetCreateTableScript(Connection conn, boolean sorted, boolean simplify)static LonggetId(Object conn)static longgetLastPacketReceivedTimeMs(Connection conn)Deprecated.static List<String>getTableDDL(Connection conn, List<String> tables)static booleanisBuiltinDataType(String dataType)static booleanisKeyword(String name)static booleanisNumber(String str)static booleanisSupportParseDateformat(String str)static voidloadDataTypes(Set<String> dataTypes)static DateparseDate(String str, TimeZone timeZone)static ZonedDateTimeparseDateTime(byte[] str, int off, int len, ZoneId zoneId)static longparseMillis(byte[] str, int off, int len, TimeZone timeZone)static longparseMillis(byte[] str, TimeZone timeZone)static TimeZoneparseTimeZone(String str)static List<String>showTables(Connection conn)static DateFormattoJavaFormat(String fmt)static DateFormattoJavaFormat(String fmt, TimeZone timeZone)static Stringutf16(String hex)static Stringutf32(String hex)static Stringutf8(String hex)
-
-
-
Method Detail
-
createXAConnection
public static XAConnection createXAConnection(Driver driver, Connection physicalConn) throws SQLException
- Throws:
SQLException
-
buildKillQuerySql
public static String buildKillQuerySql(Connection connection, SQLException error) throws SQLException
- Throws:
SQLException
-
isKeyword
public static boolean isKeyword(String name)
-
isBuiltinDataType
public static boolean isBuiltinDataType(String dataType)
-
showTables
public static List<String> showTables(Connection conn) throws SQLException
- Throws:
SQLException
-
getTableDDL
public static List<String> getTableDDL(Connection conn, List<String> tables) throws SQLException
- Throws:
SQLException
-
getCreateTableScript
public static String getCreateTableScript(Connection conn) throws SQLException
- Throws:
SQLException
-
getCreateTableScript
public static String getCreateTableScript(Connection conn, boolean sorted, boolean simplify) throws SQLException
- Throws:
SQLException
-
getLastPacketReceivedTimeMs
@Deprecated public static long getLastPacketReceivedTimeMs(Connection conn) throws SQLException
Deprecated.The lastQueryFinishedTime, returned from mysql8 com.mysql.cj.jdbc.JdbcConnection#getIdleFor, does not be updated by method pingInternal running for connection validation if option usePingMethod is true.
More troublesome is that lastQueryFinishedTime will not be set if option maintainTimeStats is false, so does mysql5 lastPacketReceivedTimeMs.- Throws:
SQLException
-
getCommunicationsExceptionClass
public static Class getCommunicationsExceptionClass()
-
decimal
public static BigDecimal decimal(BigDecimal value, int precision, int scale)
-
isNumber
public static boolean isNumber(String str)
-
toJavaFormat
public static DateFormat toJavaFormat(String fmt, TimeZone timeZone)
-
toJavaFormat
public static DateFormat toJavaFormat(String fmt)
-
parseMillis
public static long parseMillis(byte[] str, TimeZone timeZone)
-
parseMillis
public static long parseMillis(byte[] str, int off, int len, TimeZone timeZone)
-
parseDateTime
public static ZonedDateTime parseDateTime(byte[] str, int off, int len, ZoneId zoneId)
-
isSupportParseDateformat
public static boolean isSupportParseDateformat(String str)
-
-