View Javadoc

1   package de.mxro.async.map.sql.internal;
2   
3   import java.sql.Connection;
4   import java.sql.DriverManager;
5   import java.sql.SQLException;
6   
7   import de.mxro.async.map.sql.SqlConnectionConfiguration;
8   
9   public class SqlConnectionFactory {
10  
11  	public static Connection createConnection(SqlConnectionConfiguration conf) {
12  		
13  		try {
14  			Class.forName(conf.getDriverClassName());
15  		} catch (ClassNotFoundException e) {
16  			throw new RuntimeException(e);
17  		}
18  		
19  		Connection connection;
20  		try {
21  			connection = DriverManager.getConnection(conf
22  					.getConnectionString());
23  
24  			connection.setAutoCommit(false);
25  		} catch (final SQLException e) {
26  			throw new RuntimeException(e);
27  		}
28  		return connection;
29  	}
30  	
31  }