📄 mysql.java
字号:
/* Sesame - Storage and Querying architecture for RDF and RDF Schema * Copyright (C) 2001-2005 Aduna * * Contact: * Aduna * Prinses Julianaplein 14 b * 3817 CS Amersfoort * The Netherlands * tel. +33 (0)33 465 99 87 * fax. +33 (0)33 465 99 87 * * http://aduna.biz/ * http://www.openrdf.org/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package org.openrdf.sesame.sailimpl.rdbms;import java.sql.Connection;import java.sql.DatabaseMetaData;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.sql.Types;import org.openrdf.util.log.ThreadLog;/** * Defines MySQL specific SQL syntax. * * @author Arjohn Kampman */public class MySQL extends RDBMS { /** * Initializes MySQL specific SQL syntax. */ public MySQL() { super(); // the default character types are case-insensitive in // MySQL, define case-sensitive alternatives: LOCALNAME = "VARCHAR(255) BINARY"; LANGUAGE = "VARCHAR(16) BINARY"; LABEL = "BLOB"; LABEL_TYPE = Types.BLOB; PREFIX = "VARCHAR(16) BINARY"; NAME = "BLOB"; NAME_TYPE = Types.BLOB; BOOLEAN = "BOOL"; TRUE = "1"; FALSE = "0"; INFOFIELD = "VARCHAR(255) BINARY"; } protected void _initConstants(DatabaseMetaData metaData) throws SQLException { super._initConstants(metaData); int majorVersion = metaData.getDatabaseMajorVersion(); int minorVersion = metaData.getDatabaseMinorVersion(); if (majorVersion == 4 && minorVersion >= 1 || majorVersion >= 5) { // MySQL 4.1 and higher support character set and -collation specifications ThreadLog.trace("Detected MySQL 4.1 or newer, using case-sensitive utf-8 character columns"); LOCALNAME = "VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin"; LANGUAGE = "VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_bin"; LABEL = "TEXT CHARACTER SET utf8 COLLATE utf8_bin"; LABEL_TYPE = Types.LONGVARCHAR; PREFIX = "VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_bin"; NAME = "TEXT CHARACTER SET utf8 COLLATE utf8_bin"; NAME_TYPE = Types.LONGVARCHAR; INFOFIELD = "VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin"; } } /** * Overrides dropIndex in RDBMS. In MySQL, an index is identified by * both its index and table name. **/ public void dropIndex(String table, String column) throws SQLException { executeUpdate("DROP INDEX " + getIndexName(table, column) + " ON " + table); } // Overrides RDBMS.optimizeTable() public void optimizeTable(String tableName) throws SQLException { //ThreadLog.trace("optimizing table " + tableName); Connection con = getConnection(); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("OPTIMIZE TABLE " + tableName); rs.close(); st.close(); con.close(); //ThreadLog.trace("done optimizing table"); } // Overrides RDBMS._clearTable() protected void _clearTable(String tableName) throws SQLException { executeUpdate("TRUNCATE TABLE " + tableName); } public void renameTableColumn(String tableName, String currentColumnName, String newColumnName, String columnSignature) throws SQLException { executeUpdate("ALTER TABLE " + tableName + " CHANGE " + currentColumnName + " " + newColumnName + " " + columnSignature); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -