package com.ntua.db.jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import java.sql.DriverManager;

public class JdbcBaseDao {

	private static final String SQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
	private static final String JUNIT_CONNECTION_URL = "jdbc:mysql://localhost:3306/ideal_house";
	private static final String JUNIT_CONNECTION_USER = "root";
	private static final String JUNIT_CONNECTION_PASSWORD = "1234";
	
	
	public Connection getJdbcConnection() {
		Connection conn;
		try {
			Class.forName(SQL_JDBC_DRIVER);
			conn = DriverManager.getConnection(JUNIT_CONNECTION_URL,
					JUNIT_CONNECTION_USER, JUNIT_CONNECTION_PASSWORD);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			return null;
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
		
		return conn;
	}
	
	public void closeConnection(Connection con) {
		if (con != null) {
			try {
				con.close();
			} catch (SQLException se) {
				se.printStackTrace();
			}
		}
	}
	
	public void freeResultSet(ResultSet resultSet){		
		try {
			if (resultSet!=null)
				resultSet.close();			
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
	
	public void freeStatement(Statement stm){
		try{
			if (stm!=null)
				stm.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
	}
	
}

@@ -68,25 +68,21 @@
 sql.
-PreparedStatement
+DriverManager
 ;%0Aim
@@ -168,172 +168,8 @@
 t;%0A%0A
-import javax.naming.Context;%0Aimport javax.naming.InitialContext;%0Aimport javax.naming.NamingException;%0Aimport javax.sql.DataSource;%0A%0Aimport java.sql.DriverManager;%0A%0A
 publ

remove imports