Here you can find the source of getConnection()
Parameter | Description |
---|---|
connection | the connection. |
Parameter | Description |
---|---|
Exception | to JUnit. |
protected static Connection getConnection() throws Exception
//package com.java2s; import java.io.FileInputStream; import java.sql.Connection; import java.sql.DriverManager; import java.util.Properties; public class Main { private static Connection connection; /**/*www . java 2s .c om*/ * Clear the database. * * @param connection * the connection. * * @throws Exception * to JUnit. */ protected static Connection getConnection() throws Exception { if (connection == null) { Properties p = new Properties(); FileInputStream in = new FileInputStream( "test_files/stress/database.properties"); p.load(in); in.close(); Class.forName(p.getProperty("DatabaseDriver")); return DriverManager.getConnection( p.getProperty("DatabaseUrl"), p.getProperty("username"), p.getProperty("password")); } return connection; } }