1 21 22 package org.opensubsystems.core.persist.db.mysql; 23 24 import java.sql.Connection ; 25 import java.sql.SQLException ; 26 import java.sql.Statement ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 30 import org.opensubsystems.core.error.OSSException; 31 import org.opensubsystems.core.persist.db.VersionedDatabaseSchema; 32 import org.opensubsystems.core.util.DatabaseUtils; 33 import org.opensubsystems.core.util.Log; 34 35 47 public class MySQLVersionedDatabaseSchema extends VersionedDatabaseSchema 48 { 49 51 54 private static Logger s_logger = Log.getInstance(MySQLVersionedDatabaseSchema.class); 55 56 58 61 public MySQLVersionedDatabaseSchema( 62 ) throws OSSException 63 { 64 super(); 65 } 66 67 70 public void create( 71 Connection cntDBConnection, 72 String strUserName 73 ) throws SQLException 74 { 75 s_logger.entering(this.getClass().getName(), "create"); 76 77 try 78 { 79 Statement stmQuery = null; 80 try 81 { 82 83 stmQuery = cntDBConnection.createStatement(); 84 if (stmQuery.execute( 85 "create table " + SCHEMA_TABLE_NAME + NL 86 + "(" + NL 87 + " SCHEMA_NAME VARCHAR(50) NOT NULL," + NL 88 + " SCHEMA_VERSION INTEGER NOT NULL," + NL 89 + " CREATION_TIMESTAMP TIMESTAMP NOT NULL," + NL 90 + " MODIFICATION_TIMESTAMP TIMESTAMP NOT NULL," + NL 91 + " CONSTRAINT " + getSchemaPrefix() + "SCH_PK PRIMARY KEY" + 92 " (SCHEMA_NAME)" + NL 93 + ") TYPE=INNODB")) 94 { 95 stmQuery.getMoreResults(Statement.CLOSE_ALL_RESULTS); 97 } 98 s_logger.log(Level.FINEST, "Table " + SCHEMA_TABLE_NAME + " created."); 99 107 } 108 catch (SQLException sqleExc) 109 { 110 s_logger.log(Level.WARNING, "Failed to create version schema.", 112 sqleExc); 113 throw sqleExc; 114 } 115 finally 116 { 117 DatabaseUtils.closeStatement(stmQuery); 118 } 119 } 120 finally 121 { 122 s_logger.exiting(this.getClass().getName(), "create"); 123 } 124 } 125 } 126 | Popular Tags |