1 21 22 package org.opensubsystems.core.persist.db.sybase; 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.DatabaseImpl; 32 import org.opensubsystems.core.persist.db.VersionedDatabaseSchema; 33 import org.opensubsystems.core.util.DatabaseUtils; 34 import org.opensubsystems.core.util.Log; 35 36 48 public class SybaseVersionedDatabaseSchema extends VersionedDatabaseSchema 49 { 50 51 53 56 private static Logger s_logger = Log.getInstance(DatabaseImpl.class); 57 58 60 63 public SybaseVersionedDatabaseSchema( 64 ) throws OSSException 65 { 66 super(); 67 } 68 69 70 77 public void create( 78 Connection cntDBConnection, 79 String strUserName 80 ) throws SQLException 81 { 82 s_logger.entering(this.getClass().getName(), "create"); 83 84 try 85 { 86 Statement stmQuery = null; 87 try 88 { 89 90 stmQuery = cntDBConnection.createStatement(); 91 if (stmQuery.execute( 92 "create table " + SCHEMA_TABLE_NAME + NL 93 + "(" + NL 94 + " SCHEMA_NAME VARCHAR(50) NOT NULL," + NL 95 + " SCHEMA_VERSION INTEGER NOT NULL," + NL 96 + " CREATION_TIMESTAMP DATETIME NOT NULL," + NL 97 + " MODIFICATION_TIMESTAMP DATETIME NOT NULL," + NL 98 + " CONSTRAINT " + getSchemaPrefix() + "SCH_PK PRIMARY KEY" + 99 " (SCHEMA_NAME)" + NL 100 + ")")) 101 { 102 stmQuery.getMoreResults(Statement.CLOSE_ALL_RESULTS); 104 } 105 s_logger.log(Level.FINEST, "Table " + SCHEMA_TABLE_NAME + " created."); 106 114 } 115 catch (SQLException sqleExc) 116 { 117 s_logger.log(Level.WARNING, "Failed to create version schema.", 119 sqleExc); 120 throw sqleExc; 121 } 122 finally 123 { 124 DatabaseUtils.closeStatement(stmQuery); 125 } 126 } 127 finally 128 { 129 s_logger.exiting(this.getClass().getName(), "create"); 130 } 131 } 132 } 133 | Popular Tags |