Changeset 9847
- Timestamp:
- 2005-05-10T15:48:11+12:00 (19 years ago)
- Location:
- branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLConnection.java
r8773 r9847 14 14 { 15 15 16 public GS3SQLConnection(java.sql.Connection connection )16 public GS3SQLConnection(java.sql.Connection connection, String database) 17 17 { 18 super(connection );18 super(connection, database); 19 19 } 20 20 … … 25 25 } 26 26 27 27 public GS3SQLConnection cloneConnection() { 28 GS3SQLConnection conn = GS3SQLConnectionFactory.getGS3SQLConnection(this.database); 29 return conn; 30 } 28 31 /** 29 32 * Initialise a collection for use. … … 224 227 statement.execute(classData.toString()); 225 228 229 statement.close(); 226 230 // 227 231 // END OF GSDL TABLES … … 232 236 { 233 237 System.out.println(ex.toString()); 238 if (statement != null) { 239 try { 240 statement.close(); 241 } catch (Exception e){} 242 statement = null; 243 } 234 244 return false; 235 245 } -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLConnectionFactory.java
r8745 r9847 32 32 return null; 33 33 } 34 return new SQLConnection(c );34 return new SQLConnection(c, database); 35 35 } 36 36 … … 42 42 return null; 43 43 } 44 return new GS3SQLConnection(c );44 return new GS3SQLConnection(c, database); 45 45 } 46 46 -
branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/SQLConnection.java
r8745 r9847 11 11 protected Connection connection; 12 12 protected Statement statement; 13 14 15 public SQLConnection(java.sql.Connection connection )13 protected String database; 14 15 public SQLConnection(java.sql.Connection connection, String database) 16 16 { 17 17 this.connection = connection; 18 this.database = database; 18 19 } 19 20 … … 21 22 if (this.connection!=null) { 22 23 try { 23 this.connection.close(); 24 this.connection.close(); 24 25 } catch (Exception e) {} 25 26 this.connection = null;27 26 } 27 if (this.statement!=null) { 28 try { 29 this.statement.close(); 30 } catch (Exception e) {} 31 } 32 33 this.connection = null; 34 this.statement = null; 35 28 36 } 29 37 38 public void close() { 39 finalize(); 40 } 41 30 42 public boolean execute(String sql) 31 43 { 32 44 try { 45 if (this.statement != null) { 46 this.statement.close(); 47 } 33 48 this.statement = this.connection.createStatement(); 34 49 this.statement.execute(sql); … … 41 56 } 42 57 58 public void closeStatement() { 59 try { 60 if (this.statement != null) { 61 this.statement.close(); 62 } 63 } catch (Exception e) {} 64 65 } 43 66 public Statement createStatement() 44 67 { … … 67 90 68 91 public boolean connectToDatabase(String database) { 92 if (this.connection != null) { 93 try { 94 this.connection.close(); 95 } catch (Exception e) {} 96 } 69 97 this.connection = GS3SQLConnectionFactory.getConnection(database); 70 98 if (this.connection == null) { 71 99 return false; 72 100 } 101 this.database = database; 73 102 return true; 74 103 } … … 78 107 this.statement = this.connection.createStatement(); 79 108 this.statement.execute("DROP DATABASE "+database+";"); 109 this.statement.close(); 80 110 } 81 111 catch (SQLException ex){ … … 92 122 this.statement = this.connection.createStatement(); 93 123 this.statement.execute(command); 124 this.statement.close(); 94 125 } catch (Exception e) { 95 126 System.err.println(e);
Note:
See TracChangeset
for help on using the changeset viewer.