I have made a db connection to fetch from data in the code and now i need to keep this Db instance global and need to use in the other parts of the project.

Please guide me on the same.

I have the below code

```
try
    {   
        // load the DB2 Driver
        Class.forName("com.ibm.db2.jcc.DB2Driver");
        // establish a connection to DB2
        Connection db2Conn = DriverManager.getConnection
        (dbUrl,"wcsadm",dbPass);
        // use a statement to gather data from the database
        Statement st = db2Conn.createStatement();
        String myQuery=null;
        String insQuery=null;
        myQuery = "my query"
        // execute the query
        ResultSet resultSet = st.executeQuery(myQuery); 
        // cycle through the resulSet and display what was grabbed
        while (resultSet.next())
        {
        //do something
        }
        resultSet.close();
        st.close();
        db2Conn.close();
    }

```