/* * Copyright (c) 2003,2004 Aly Merchant * * This software is provided 'as-is', without any express or implied warranty. * In no event will the authors be held liable for any damages arising from the * use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * * 2. Altered source versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * 3. This notice may not be removed or altered from any source * distribution. */ package tenk; import java.io.*; import java.util.*; import java.sql.*; public class Data { private static String dbServer = null, dbName = null, dbUser = null, dbPass = null, dbType = null, dbDriver = null; private static int dbPort = -1; private static boolean usingDB = true; private static Properties p = null; private static Connection c = null; public static boolean getUsingDB() { return usingDB; } public static void setUsingDB(boolean u) { usingDB = u; } public static boolean isConnected() { return c != null; } public static void setDB() { setDB("db.cfg"); } public static void setDB( String propFile ) { try { FileInputStream fis = new FileInputStream(propFile); p = new Properties(); p.load( fis ); dbServer = p.getProperty("server"); dbName = p.getProperty("db"); dbUser = p.getProperty("user"); dbPass = p.getProperty("pass"); dbDriver = p.getProperty("driver"); dbType = p.getProperty("type"); dbPort = (p.getProperty("port") == null) ? -1 : Integer.parseInt(p.getProperty("port")); } catch (IOException ioe) { System.out.println("Problem in file reading: "+ioe.getMessage()); ioe.printStackTrace(); } } private static HashMap mr = new HashMap(), fr = new HashMap(); public static String sqlify(String s) { for (int i=0; i