Dear my friends... I have 3 classes in my Java program One is Menu class, Konek (Connection) Class and Control Class. I want to put my connection code into one class but I don't know how to make another class can use the same connection, such as under below in my code.... I tried to pass the "conn" from koneksi.konek() like this : conn=koneksi.konek() but the output data type doesn't give me any possibility because the datatype of "conn" is Connection whereas I only may put : String, int, void etc. Should I use ADT in this case? Thanks in advance... ==== import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.*; class menu{ public static char start() { char pilihmenu; System.out.println("Here is customer menu\n\n"); System.out.println("========================================="); System.out.println("| Main Menu |"); System.out.println("========================================="); System.out.println("| Options : |"); System.out.println("| 1. Customer |"); System.out.println("| 2. Product Field |"); System.out.println("========================================="); pilihmenu = Keyin.inChar("Please choose (1-2) : "); return pilihmenu; } public static void customer() { try { koneksi.konek(); // Do something with the Connection // assume conn is an already created JDBC connection Statement stmt = null; ResultSet rs = null; try { //stmt = conn.createStatement(); //here is the problem. How can I make the "conn" connection variable be usable by this class and this method? In order to make my program can execute the query furthermore. I hate to make so many times Connection String in every time I need it. I want only in one method of one class. System.out.println("Executing query.\n"); rs = stmt.executeQuery("SELECT customerid FROM customer"); .... .... } finally { // it is a good idea to release // resources in a finally{} block // in reverse-order of their creation // if they are no-longer needed System.out.println("Error in Query.\n"); if (rs != null) { try { rs.close(); } catch (SQLException sqlEx) { // ignore } rs = null; } if (stmt != null) { try { stmt.close(); } catch (SQLException sqlEx) { // ignore } stmt = null; } } } } }catch (Exception e) { // handle any errors } } } class koneksi{ public static void konek(){ System.out.println("Building connection to database.\n"); try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/amt?user=root&password=pandawa5"); System.out.println("Connection established.: "+ conn+"\n"); // Do something with the Connection // assume conn is an already created JDBC connection }catch (Exception e) { // handle any errors System.out.println("Connection failed.\n"); } } } public class comadmin { public static void main(String[] args){ char pilihmenu; pilihmenu = menu.start(); System.out.println("Your choice is : "+pilihmenu+"\n"); if (pilihmenu== '1'){ System.out.println("Opening customer menu\n"); menu.customer(); } } } __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/