1 21 22 package org.opensubsystems.core.persist.db.mssql; 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 MSSQLVersionedDatabaseSchema extends VersionedDatabaseSchema 48 { 49 50 52 55 private static Logger s_logger = Log.getInstance(MSSQLVersionedDatabaseSchema.class); 56 57 59 62 public MSSQLVersionedDatabaseSchema( 63 ) throws OSSException 64 { 65 super(); 66 } 67 68 70 73 public void create( 74 Connection cntDBConnection, 75 String strUserName 76 ) throws SQLException 77 { 78 s_logger.entering(this.getClass().getName(), "create"); 79 80 try 81 { 82 Statement stmQuery = null; 83 try 84 { 85 86 stmQuery = cntDBConnection.createStatement(); 87 if (stmQuery.execute( 88 "create table " + SCHEMA_TABLE_NAME + NL 89 + "(" + NL 90 + " SCHEMA_NAME VARCHAR(50) NOT NULL," + NL 91 + " SCHEMA_VERSION INTEGER NOT NULL," + NL 92 + " CREATION_TIMESTAMP DATETIME NOT NULL," + NL 93 + " MODIFICATION_TIMESTAMP DATETIME NOT NULL," + NL 94 + " CONSTRAINT " + getSchemaPrefix() + "SCH_PK PRIMARY KEY" + 95 " (SCHEMA_NAME)" + NL 96 + ")")) 97 { 98 stmQuery.getMoreResults(Statement.CLOSE_ALL_RESULTS); 100 } 101 s_logger.log(Level.FINEST, "Table " + SCHEMA_TABLE_NAME + " created."); 102 110 } 111 catch (SQLException sqleExc) 112 { 113 s_logger.log(Level.WARNING, "Failed to create version schema.", 115 sqleExc); 116 throw sqleExc; 117 } 118 finally 119 { 120 DatabaseUtils.closeStatement(stmQuery); 121 } 122 } 123 finally 124 { 125 s_logger.exiting(this.getClass().getName(), "create"); 126 } 127 } 128 } 129 | Popular Tags |