I'm new in java and JDBC but I?m trying to make a database connection to MS Access2000 with the following code (see after a few line of my question) i'm trying to make two methods one will create a new connection and second is for closing the already opened connection but second method (connection closing method)isn?t working properly I want 2 execute if part of the code but java execute else part of the code what is wrong with this code
Can anybody help me about the following code I?m copying each line of my code of MyFirstConnection dot java file which is following. is there a better way to do this code this?
import java.sql.*;
public class MyFIrstConnection { static Connection conn; public static Connection getConnection(Connection connection){ if(connection == null){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection("jdbc:odbc:nwind","",""); System.out.println("Connection Successeded"); return connection; }catch(SQLException sqle){ System.out.println("Error while Connecting Database"); sqle.printStackTrace(); return null;