Returns connection to core schema in database @param ApplicationRoot @return Connection to core schema with admin privileges
(String ApplicationRoot)
| 93 | * @return Connection to core schema with admin privileges |
| 94 | */ |
| 95 | public static Connection getCoreConnection(String ApplicationRoot) |
| 96 | { |
| 97 | Connection conn = null; |
| 98 | try |
| 99 | { |
| 100 | //log.debug("Getting Prop File"); |
| 101 | //Pull Driver and DB URL out of database.properties |
| 102 | |
| 103 | String props = Constants.DBPROP; |
| 104 | |
| 105 | //log.debug("Getting Driver"); |
| 106 | String DriverType = FileInputProperties.readfile(props, "DriverType"); |
| 107 | //log.debug("Getting Driver Instance"); |
| 108 | Class.forName(DriverType).newInstance(); |
| 109 | String connectionURL=FileInputProperties.readfile(props, "databaseConnectionURL"); |
| 110 | |
| 111 | //Pull Schema, User name and Password from SqlInjLesson.properties |
| 112 | |
| 113 | //log.debug("Reading Prop File"); |
| 114 | connectionURL= connectionURL + FileInputProperties.readfile(props, "databaseSchema"); |
| 115 | String username=FileInputProperties.readfile(props, "databaseUsername"); |
| 116 | String password=FileInputProperties.readfile(props, "databasePassword"); |
| 117 | |
| 118 | //log.debug("Creating Connection to DB"); |
| 119 | conn = DriverManager.getConnection(connectionURL,username,password); |
| 120 | } |
| 121 | catch(Exception e) |
| 122 | { |
| 123 | log.fatal("Unable to create database connection: " + e); |
| 124 | e.printStackTrace(); |
| 125 | } |
| 126 | return conn; |
| 127 | } |
| 128 | |
| 129 | public static Connection getDatabaseConnection(String ApplicationRoot) { |
| 130 | return getDatabaseConnection(ApplicationRoot, false); |