?? mysqldefs.java
字號(hào):
/* Copyright (C) 2002-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. There are special exceptions to the terms and conditions of the GPL as it is applied to this software. View the full text of the exception in file EXCEPTIONS-CONNECTOR-J in the directory of this software distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *//* * This program is free software; you can redistribute it and/or modify it under the terms of * the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with this program; * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */package com.meidusa.amoeba.mysql.jdbc;import java.sql.Types;import java.util.HashMap;import java.util.Iterator;import java.util.Map;/** * copy from mysql-connector-j MysqlDefs contains many values that are needed * for communication with the MySQL server. * * @author Mark Matthews * @version $Id: MysqlDefs.java 4724 2005-12-20 23:27:01Z mmatthews $ */public final class MysqlDefs { // ~ Static fields/initializers // --------------------------------------------- public static final int COM_BINLOG_DUMP = 18; public static final int COM_CHANGE_USER = 17; public static final int COM_CLOSE_STATEMENT = 25; public static final int COM_CONNECT_OUT = 20; public static final int COM_END = 29; public static final int COM_EXECUTE = 23; public static final int COM_FETCH = 28; public static final int COM_LONG_DATA = 24; public static final int COM_PREPARE = 22; public static final int COM_REGISTER_SLAVE = 21; public static final int COM_RESET_STMT = 26; public static final int COM_SET_OPTION = 27; public static final int COM_TABLE_DUMP = 19; public static final int CONNECT = 11; public static final int CREATE_DB = 5; public static final int DEBUG = 13; public static final int DELAYED_INSERT = 16; public static final int DROP_DB = 6; public static final int FIELD_LIST = 4; public static final int FIELD_TYPE_BIT = 16; public static final int FIELD_TYPE_BLOB = 252; public static final int FIELD_TYPE_DATE = 10; public static final int FIELD_TYPE_DATETIME = 12; // Data Types public static final int FIELD_TYPE_DECIMAL = 0; public static final int FIELD_TYPE_DOUBLE = 5; public static final int FIELD_TYPE_ENUM = 247; public static final int FIELD_TYPE_FLOAT = 4; public static final int FIELD_TYPE_GEOMETRY = 255; public static final int FIELD_TYPE_INT24 = 9; public static final int FIELD_TYPE_LONG = 3; public static final int FIELD_TYPE_LONG_BLOB = 251; public static final int FIELD_TYPE_LONGLONG = 8; public static final int FIELD_TYPE_MEDIUM_BLOB = 250; public static final int FIELD_TYPE_NEW_DECIMAL = 246; public static final int FIELD_TYPE_NEWDATE = 14; public static final int FIELD_TYPE_NULL = 6; public static final int FIELD_TYPE_SET = 248; public static final int FIELD_TYPE_SHORT = 2; public static final int FIELD_TYPE_STRING = 254; public static final int FIELD_TYPE_TIME = 11; public static final int FIELD_TYPE_TIMESTAMP = 7; public static final int FIELD_TYPE_TINY = 1; // Older data types public static final int FIELD_TYPE_TINY_BLOB = 249; public static final int FIELD_TYPE_VAR_STRING = 253; public static final int FIELD_TYPE_VARCHAR = 15; // Newer data types public static final int FIELD_TYPE_YEAR = 13; public static final int INIT_DB = 2; public static final long LENGTH_BLOB = 65535; public static final long LENGTH_LONGBLOB = 4294967295L; public static final long LENGTH_MEDIUMBLOB = 16777215; public static final long LENGTH_TINYBLOB = 255; // Limitations public static final int MAX_ROWS = 50000000; // From the MySQL FAQ /** * Used to indicate that the server sent no field-level character set * information, so the driver should use the connection-level character * encoding instead. */ public static final int NO_CHARSET_INFO = -1; public static final byte OPEN_CURSOR_FLAG = 1; public static final int PING = 14; public static final int PROCESS_INFO = 10; public static final int PROCESS_KILL = 12; public static final int QUERY = 3; public static final int QUIT = 1; // ~ Methods // ---------------------------------------------------------------- public static final int RELOAD = 7; public static final int SHUTDOWN = 8; // // Constants defined from mysql // // DB Operations public static final int SLEEP = 0; public static final int STATISTICS = 9; public static final int TIME = 15; /** * Maps the given MySQL type to the correct JDBC type. */ public static int mysqlToJavaType(int mysqlType) { int jdbcType; switch (mysqlType) { case MysqlDefs.FIELD_TYPE_NEW_DECIMAL: case MysqlDefs.FIELD_TYPE_DECIMAL: jdbcType = Types.DECIMAL; break; case MysqlDefs.FIELD_TYPE_TINY: jdbcType = Types.TINYINT; break; case MysqlDefs.FIELD_TYPE_SHORT: jdbcType = Types.SMALLINT; break; case MysqlDefs.FIELD_TYPE_LONG: jdbcType = Types.INTEGER; break; case MysqlDefs.FIELD_TYPE_FLOAT: jdbcType = Types.REAL; break; case MysqlDefs.FIELD_TYPE_DOUBLE: jdbcType = Types.DOUBLE; break; case MysqlDefs.FIELD_TYPE_NULL: jdbcType = Types.NULL; break; case MysqlDefs.FIELD_TYPE_TIMESTAMP: jdbcType = Types.TIMESTAMP; break; case MysqlDefs.FIELD_TYPE_LONGLONG: jdbcType = Types.BIGINT; break; case MysqlDefs.FIELD_TYPE_INT24: jdbcType = Types.INTEGER; break; case MysqlDefs.FIELD_TYPE_DATE: jdbcType = Types.DATE; break; case MysqlDefs.FIELD_TYPE_TIME: jdbcType = Types.TIME; break; case MysqlDefs.FIELD_TYPE_DATETIME: jdbcType = Types.TIMESTAMP; break; case MysqlDefs.FIELD_TYPE_YEAR: jdbcType = Types.DATE; break; case MysqlDefs.FIELD_TYPE_NEWDATE: jdbcType = Types.DATE; break; case MysqlDefs.FIELD_TYPE_ENUM: jdbcType = Types.CHAR; break; case MysqlDefs.FIELD_TYPE_SET: jdbcType = Types.CHAR; break; case MysqlDefs.FIELD_TYPE_TINY_BLOB: jdbcType = Types.VARBINARY; break; case MysqlDefs.FIELD_TYPE_MEDIUM_BLOB: jdbcType = Types.LONGVARBINARY; break; case MysqlDefs.FIELD_TYPE_LONG_BLOB: jdbcType = Types.LONGVARBINARY; break; case MysqlDefs.FIELD_TYPE_BLOB: jdbcType = Types.LONGVARBINARY; break; case MysqlDefs.FIELD_TYPE_VAR_STRING: case MysqlDefs.FIELD_TYPE_VARCHAR: jdbcType = Types.VARCHAR; break; case MysqlDefs.FIELD_TYPE_STRING: jdbcType = Types.CHAR; break; case MysqlDefs.FIELD_TYPE_GEOMETRY: jdbcType = Types.BINARY; break; case MysqlDefs.FIELD_TYPE_BIT: jdbcType = Types.BIT; break; default: jdbcType = Types.VARCHAR; } return jdbcType; } public static int javaTypeDetect(int javaType, int scale) { switch (javaType) { case Types.NUMERIC: { if (scale > 0) { return Types.DECIMAL; }else{ return javaType; } } default: { return javaType; } } } public static int javaTypeMysql(int javaType) { switch (javaType) { case Types.NUMERIC: return MysqlDefs.FIELD_TYPE_LONG; case Types.DECIMAL: return MysqlDefs.FIELD_TYPE_NEW_DECIMAL; case Types.TINYINT: return MysqlDefs.FIELD_TYPE_TINY; case Types.SMALLINT: return MysqlDefs.FIELD_TYPE_SHORT; case Types.INTEGER: return MysqlDefs.FIELD_TYPE_LONG; case Types.REAL: return MysqlDefs.FIELD_TYPE_FLOAT; case Types.DOUBLE: return MysqlDefs.FIELD_TYPE_DOUBLE; case Types.NULL: return MysqlDefs.FIELD_TYPE_NULL; case Types.TIMESTAMP: return MysqlDefs.FIELD_TYPE_TIMESTAMP; case Types.BIGINT: return MysqlDefs.FIELD_TYPE_LONGLONG; case Types.DATE: return MysqlDefs.FIELD_TYPE_DATE;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -