Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection getConnection() throws SQLException {
- return DriverManager.getConnection("jdbc:neo4j:bolt://localhost:port");
- }
- public Connection getConnection(String username, String password) throws SQLException {
- return DriverManager.getConnection("jdbc:neo4j:bolt://localhost:port");
- }
- @Override
- public PrintWriter getLogWriter() throws SQLException {
- return pw;
- }
- @Override
- public void setLogWriter(PrintWriter out) throws SQLException {
- pw = out;
- }
- @Override
- public void setLoginTimeout(int seconds) throws SQLException {
- }
- @Override
- public int getLoginTimeout() throws SQLException {
- return 0;
- }
- @Override
- public <T> T unwrap(Class<T> iface) throws SQLException {
- return ConnectionPoolDataSource.class.equals(iface) ? (T) this : super.unwrap(iface);
- }
- @Override
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
- return ConnectionPoolDataSource.class.equals(iface) || super.isWrapperFor(iface);
- }
- @Override
- public PooledConnection getPooledConnection() throws SQLException {
- System.out.println("Inside getPooledConnection with args + Neo4jConnectionPoolDataSource");
- return new Neo4jPooledConnection(null,null);
- }
- @Override
- public PooledConnection getPooledConnection(String paramString1,
- String paramString2) throws SQLException {
- return new Neo4jPooledConnection("username","password");
- }
- public class Neo4jPooledConnection implements PooledConnection {
- private Connection con;
- private String user;
- private String password;
- public Neo4jPooledConnection(String user, String password)
- {
- this.con = con;
- this.user = user;
- this.password = password;
- }
- public void addConnectionEventListener(ConnectionEventListener connectionEventListener)
- { }
- public void removeConnectionEventListener(ConnectionEventListener connectionEventListener)
- { }
- public void close()
- throws SQLException
- {
- if (con != null) {
- con.close();
- con = null;
- }
- }
- public Connection getConnection() throws SQLException {
- if (con == null || con.isClosed()) {
- con = ((user == null)
- ? Neo4jConnectionPoolDataSource.this.getConnection()
- : Neo4jConnectionPoolDataSource.this.getConnection(user, password));
- return con;
- } else
- { throw new IllegalStateException();}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement