2 Replies Latest reply: May 9, 2008 1:54 AM by 801523 RSS

    Sun support for mysql and jdbc

      Has anyone had success using Eclipse as the IDE and working with mysql via the jdbc?
      I didn't see Eclipse mentioned on the mysql site.
        • 1. Re: Sun support for mysql and jdbc
          Yes, I have. No doubt thousands of others have as well. But that seems an odd sort of question. Usually people post problems here. Trying to do surveys here isn't likely to get you useful information.
          • 2. Re: Sun support for mysql and jdbc
            I can able to connect MySQL database from Eclipse 3.1.2 IDE with JDBC.

            below is sample code
            import java.sql.Connection;
            import java.sql.DriverManager;
            import java.sql.ResultSet;
            import java.sql.SQLException;
            import java.sql.Statement;
            import java.util.Date;

            public class MySqlTest {

            public static void main(String args[]) {
            Connection con = null;

            try {
            con = DriverManager.getConnection("jdbc:mysql://localhost/test",
            "root", "test");
            Statement st= con.createStatement();
            ResultSet rs = st.executeQuery ("select * from registration");
            while (rs.next())
                 System.out.println( rs.getLong("id"));
                 System.out.println( rs.getDate("regdate"));
                 /* float f= rs.getLong("id");
                 Date date=rs.getDate("regdate");
                      System.out.println( date);*/
            System.out.println("Successfully connected to " +
            "MySQL server using TCP/IP...");
            System.out.println("Successfully connected to".substring(0,4));
            } catch(ArithmeticException ae) {
            System.err.println("Exception: " + ae.getMessage());


            catch(Exception e) {
            System.err.println("Exception: " + e.getMessage());

            } finally {
            try {
            if(con != null)
            } catch(SQLException e) {}


            Edited by: pvmk on May 8, 2008 11:53 PM