Á¦°¡ ¾à°£ ¼öÁ¤Çߴµ¥ tableÀÌ »ý¼ºÀÌ ¾ÈµË´Ï´Ù.
HashMap ºÎºÐ¿¡¼ <String,Object> ÇÏ°í Class.forName("oracle.jdbc.driver.OracleDriver");
À¸·Î ¹Ù²Ù¾ú½À´Ï´Ù. ±×·±µ¥ ±âÃÊ Å×À̺íÀÌ »ý¼ºÀÌ ¾ÈµÅ³×¿ä.Tomcat5.1¿¡¼ ¼öÇàÇß½À´Ï´Ù.
public boolean dbConfig(String username, String password, String url, String characterset) {
ResourceBundle bundle = null;
Connection connection = null;
Statement statement = null;
boolean result = true;
try {
bundle = ResourceBundle.getBundle("db");
Class.forName("oracle.jdbc.driver.OracleDriver");
// Class.forName("org.gjt.mm.mysql.Driver");
connection = DriverManager.getConnection(url, username, password);
statement = connection.createStatement();
HashMap<String,Object> db = new HashMap<String,Object>();
Enumeration enumeration = bundle.getKeys();
while (enumeration.hasMoreElements()) {
boolean exists = false;
String bkey = (String)enumeration.nextElement();
String value = bundle.getString(bkey);
db.put(bkey, value);
}
for (int i = 0; i < 100; i++) {
String keys = "query"+(i<10? "0"+i:""+i);
if (db.containsKey(keys)) {
String query = (String)db.get(keys);
int key = Integer.parseInt(keys.substring(5,7));
try {
if("456".indexOf(characterset) > -1) query = ko(query);
else if ("789".indexOf(characterset) > -1) query = en(query);
else query = query;
statement.executeUpdate(query);
if (key < 20)
log(ko("key "+key+" : Å×ÀÌºí »ý¼º µÇ¾ú½À´Ï´Ù"));
else if (30 <= key && key < 40)
log(ko("key "+key+" : À妽º°¡ »ý¼º µÇ¾ú½À´Ï´Ù"));
else if (40 <= key && key < 50)
log(ko("key "+key+" : µ¥ÀÌÅÍ ÃʱâÈ ½ÇÇàµÇ¾ú½À´Ï´Ù"));
else if (50 <= key)
log(ko("key "+key+" : ÃʱⵥÀÌÅÍ ÀÔ·Â ½ÇÇàµÇ¾ú½À´Ï´Ù"));
} catch (SQLException sqle) {
if (key < 20)
log(ko("key "+key+" : Á¸ÀçÇÏ´Â Å×À̺íÀÔ´Ï´Ù"));
else if (30 <= key && key < 40)
log(ko("key "+key+" : ÀÌ¹Ì Á¸ÀçÇÏ´Â À妽º ÀÔ´Ï´Ù"));
else if (40 <= key && key < 50)
log(ko("key "+key+" : µ¥ÀÌÅÍ ÃʱâÈ ½ÇÆеǾú½À´Ï´Ù"));
else if (50 <= key)
log(ko("key "+key+" : ÃʱⵥÀÌÅÍ ÀÔ·Â ½ÇÆеǾú½À´Ï´Ù"));
}
}
}
} catch (Exception e) {
result = false;
log(e.toString());
} finally {
if (statement != null) try { statement.close(); } catch (Exception ignre) {}
if (connection != null) try { connection.close(); } catch (Exception ignre) {}
}
return result;
}