01: package org.objectweb.salome_tmf.databaseSQL;
02:
03: import java.sql.PreparedStatement;
04:
05: import org.objectweb.salome_tmf.api.Util;
06:
07: public class SQLEngineGForge extends SQLEngine {
08: static DataBase db_gforge;
09:
10: static String driver_postgres = "org.postgresql.Driver";
11: static String gforge_host = "g-salome.rd.francetelecom.fr";
12: static String gforge_bdd = "gforge";
13: static String gforge_user = "salome";
14: static String gforge_pwd = "sa10me";
15:
16: static void initSQLEngine(DataBase database, boolean doLockOnQuery,
17: int locktype) throws Exception {
18: SQLEngine
19: .initSQLEngine(database, doLockOnQuery, null, locktype);
20: initGForgeDB();
21: }
22:
23: static void initGForgeDB() throws Exception {
24: String URLDB_Gforge = "jdbc:postgresql://" + gforge_host + "/"
25: + gforge_bdd;
26: if (db_gforge == null) {
27: db_gforge = new DataBase(driver_postgres);
28: db_gforge.open(URLDB_Gforge, gforge_user, gforge_pwd);
29: }
30: //System.out.println("GFORGE DB = "+ db_gforge);
31:
32: }
33:
34: static void initDB(DataBase database) throws Exception {
35: if (database == null) {
36: throw new Exception(
37: "[SQLEngine:initSQLEngine] Database is null");
38: }
39: db = database;
40: initGForgeDB();
41: }
42:
43: static PreparedStatement getSQLSelectGForgeQuery(String queryName)
44: throws Exception {
45: if (db_gforge == null) {
46: initGForgeDB();
47: }
48: Util.log("[SQLEngine->getSQLSelectQuery]" + queryName);
49: String sql = selectSqlQuery.getProperty(queryName);
50: Util.log("[SQLEngine->getSQLSelectQuery] sql is " + sql);
51: PreparedStatement prep = db_gforge.prepareStatement(sql);
52: return prep;
53: }
54:
55: public void close() throws Exception {
56: Util.log("[SQLEngine->close] close connection " + db.cnt);
57: //Util.log("[SQLEngine->close] close connection " + db_gforge.cnt);
58: db.cnt.close();
59: db = null;
60: closeGforgeDB();
61: }
62:
63: static void closeGforgeDB() throws Exception {
64: //Util.log("[SQLEngine->close] close connection " + db_gforge.cnt);
65: if (db_gforge != null) {
66: db_gforge.cnt.close();
67: db_gforge = null;
68: }
69: }
70:
71: }
|