Hi, I am using the following code but not getting a connection. :( Can someone tell me what I am doing incorrectly?
Thanks, Scott package database_test; import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager; import java.sql.SQLException; // Notice, do not import com.mysql.jdbc.* // or you will have problems! /** * <p>Title: Phone # regex: ^([(]?\d{3}[-)]\d{3}-\d{4})*$ </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author unascribed * @version 1.0 */ public class DBConnector { //Class State private String dbuser,dbpasswd,dburl; public DBConnector() { dbuser="sspiegler"; dbpasswd="cuatro"; dburl= "jdbc:mysql://localhost:3306/menagerie?user="+dbuser+"&password="+dbpasswd; } public DBConnector(String aDburl,String aDbuser,String aDbpasswd) { this.dbuser=aDbuser; this.dbpasswd=aDbpasswd; this.dburl=aDburl; } public Connection getConnection () throws SQLException { ResultSet rs=null; Connection conn=null; try { conn = DriverManager.getConnection(dburl); Statement state = conn.createStatement(); rs = state.executeQuery("SELECT * FROM pets"); if (rs != null) { // here you would do something with the ResultSet } } finally { if (rs != null) { rs.close(); } } return conn; } /** * *** for testing purposes only *** */ public static void main(String[] args) { Connection conn = null; DBConnector dbc = new DBConnector(); try { conn = dbc.getConnection(); } catch(SQLException sqle) { System.out.println("SQLException: " + sqle.getMessage()); System.out.println("SQLState: " + sqle.getSQLState()); System.out.println("VendorError: " + sqle.getErrorCode()); } } } ===== We don't see things as they are, we see things as we are. --Anais Nin __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]