# HG changeset patch # User David Van Couvering # Date 1225221578 25200 # Node ID a1b3533332b5fa919f206e22885dae00aae5d013 # Parent b5d4a0a75ea1a448109602742ef710ae27a1495d #150422: Sample DB can't be created without InnoDB diff -r d -r b -r . -r m -r y -r s -r q -r l -r / -r s -r r -r c -r / -r o -r r -r g -r / -r n -r e -r t -r b -r e -r a -r n -r s -r / -r m -r o -r d -r u -r l -r e -r s -r / -r d -r b -r / -r m -r y -r s -r q -r l -r / -r i -r m -r p -r l -r / -r B -r a -r s -r e -r S -r a -r m -r p -r l -r e -r P -r r -r o -r v -r i -r d -r e -r r -r . -r j -r a -r v -r a db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java --- a/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java +++ b/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java @@ -43,6 +43,9 @@ import java.io.File; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; @@ -96,6 +99,10 @@ public class BaseSampleProvider implemen throw new DatabaseException(getMessage("MSG_SampleNotSupported", sampleName)); } + if (! checkInnodbSupport(dbconn.getJDBCConnection())) { + throw new DatabaseException("MSG_NoSampleWithoutInnoDB"); // NOI8N + } + String sql = getSqlText(sampleName); SQLExecutor.execute(dbconn, sql); @@ -103,6 +110,22 @@ public class BaseSampleProvider implemen public boolean supportsSample(String name) { return SAMPLES.contains(name); + } + private boolean checkInnodbSupport(Connection conn) throws DatabaseException { + try { + ResultSet rs = conn.createStatement().executeQuery("SHOW STORAGE ENGINES"); // NOI18N + + while (rs.next()) { + if ("INNODB".equals(rs.getString(1).toUpperCase()) && + ("YES".equals(rs.getString(2).toUpperCase()) || "DEFAULT".equals(rs.getString(2).toUpperCase()))) { // NOI18N + return true; + } + } + + return false; + } catch (SQLException sqle) { + throw new DatabaseException(sqle); + } } public List getSampleNames() { diff -r d -r b -r . -r m -r y -r s -r q -r l -r / -r s -r r -r c -r / -r o -r r -r g -r / -r n -r e -r t -r b -r e -r a -r n -r s -r / -r m -r o -r d -r u -r l -r e -r s -r / -r d -r b -r / -r m -r y -r s -r q -r l -r / -r i -r m -r p -r l -r / -r B -r u -r n -r d -r l -r e -r . -r p -r r -r o -r p -r e -r r -r t -r i -r e -r s db.mysql/src/org/netbeans/modules/db/mysql/impl/Bundle.properties --- a/db.mysql/src/org/netbeans/modules/db/mysql/impl/Bundle.properties +++ b/db.mysql/src/org/netbeans/modules/db/mysql/impl/Bundle.properties @@ -58,6 +58,7 @@ MSG_CheckStart=The settings for starting MSG_CheckStart=The settings for starting MySQL have changed. Do you want to start the server now? MSG_UnableToStopServer=Encountered an error while trying to stop the MySQL server MSG_UnableToStartServer=Encountered an error while trying to start the MySQL server +MSG_NoSampleWithoutInnoDB=The sample requires the InnoDB storage engine, and this engine is not enabled on the server. Please enable InnoDB and try again. StartManager.CancelButton=Cancel StartManager.CancelButtonA11yDesc=Cancel start of MySQL server StartManager.KeepWaitingButton=Keep Waiting