我收到以下 MySQL 错误:
Too many keys specified; max 64 keys allowed.
Run Code Online (Sandbox Code Playgroud)
是否可以增加 MySQL 中的最大索引大小,如果可以,那么我们该怎么做?
我需要在表中询问我的列jdbc类型,今天我循环抛出我的列,然后询问它的类型,请参阅下面的代码:
public int getColumnDataTypeFromDB(String columnName) {
int datatype = 0;
ResultSet columns = null;
try {
String schema =
getMetaDataCatalogName() != null
? getMetaDataCatalogName()
: getMetaDataSchemaName();
if (TableManagerFactory.isCatalogBasedDatabase()) {
columns =
getMetaData().getColumns(
schema,
null,
tableName,
columnName);
} else {
columns =
getMetaData().getColumns(
null,
schema,
tableName,
columnName);
}
// columns =
// getMetaData().getColumns(getMetaDataCatalogName(), getMetaDataSchemaName(), tableName, columnName);
if (columns.next()) {
datatype = columns.getInt("DATA_TYPE");
}
} catch (SQLException ex) {
Log.error(
this,
"Error while getting columns information: " + ex.getMessage(),
ex);
//return false; …Run Code Online (Sandbox Code Playgroud) 我有这个代码,这段代码基本上设置了限制,PreparedStatement以避免加载整个表数据.
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
if (getDataSheet().isPagingEnabled()) {
pstmt.setFetchSize(getDataSheet().getPageSize() + 1);
}
if (getDataSheet().isDisableTotalRowsCount() && maxRecords >= 0) {
if (getDataSheet().isPagingEnabled()) {
pstmt.setMaxRows(getCurrentPageSize());
} else {
pstmt.setMaxRows(maxRecords);
}
}
//the rest of code.
} catch(Exception ex) {
//handle exception
}
Run Code Online (Sandbox Code Playgroud)
这段代码适用于所有数据库供应商,除了Oracle驱动程序中的一个案例,如果我使用setFetchSize了PreparedStatement,并且页面大小超过20000,则驱动程序抛出OutOfMemoryError
Caused by: java.lang.OutOfMemoryError: Java heap space
at oracle.jdbc.driver.PhysicalConnection.getCharBuffer(PhysicalConnection.java:7018)
at oracle.jdbc.driver.OracleStatement.prepareAccessors(OracleStatement.java:907)
at oracle.jdbc.driver.T4CTTIdcb.receiveCommon(T4CTTIdcb.java:261)
at oracle.jdbc.driver.T4CTTIdcb.receive(T4CTTIdcb.java:127)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:992)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866) …Run Code Online (Sandbox Code Playgroud) 我必须在我的项目中使用lucene创建全文搜索,所以我必须索引mysql数据库中的blob列(包含文件pdf,doc,xsl,xml和image),使用doc,xsl和xml我没有任何问题但是使用pdf文件我无法获得结果
public class Indexfile {
public static void main(String[] args) throws Exception {
RemoteControlServiceConnection a = new RemoteControlServiceConnection(
"jdbc:mysql://localhost:3306/Test","root", "root" );
Connection conn = a.getConnexionMySQL();
final File INDEX_DIR = new File("index");
IndexWriter writer = new IndexWriter(INDEX_DIR,
new StandardAnalyzer(),
true);
String query = "SELECT id, name ,document FROM Table_document";
Statement statement = conn.createStatement();
ResultSet result = statement.executeQuery(query);
while (result.next()) {
Document document = new Document();
document.add(new Field("id", result.getString("id"), Field.Store.YES, Field.Index.NO));
document.add(new Field("name", result.getString("name"), Field.Store.YES, Field.Index.TOKENIZED));
document.add(new Field("document", result.getString("document"), Field.Store.YES, Field.Index.TOKENIZED));
writer.addDocument(text); …Run Code Online (Sandbox Code Playgroud)