Hi all
I am new to java programming.
I need a litte helop.
I want to take some results from database so i am trying to connect to database. I have dowloaded jdbcmysql connector but having no idea how to add it in eclipse or jre. Plus i am having this code so please check and tell where might be i'm wrong

Statement stmt;
        ResultSet rs;
    Class.forName("com.mysql.jdbc.Driver");
                String connectionUrl = "jdbc:mysql://localhost/test?user=root&password=";
                Connection con = DriverManager.getConnection(connectionUrl);

    stmt= con.createStatement();

    rs=stmt.executeQuery("select * from atunesblue");
    String pname=rs.getString("projectname");
    String pnm = "atunesblue";
    while(rs.next()){
        if(pnm.equalsIgnoreCase(pname))
        {
            System.out.println("Mubarkaannnnnnnnnnn");
        }
        else
        {
            System.out.println("fitay munh");
        }
    }


    }
    catch (Exception e){
    System.out.println(e.getMessage());
    }

any help will be appreciated.
in response i am getting this as output
"Before start of result set"

seems like a weird output to me. anyway, in your package explorer it's pretty easy to add external libraries to your project.
some pointers though:
1. don't hardcode username and password and other DB specific info. store them in properties or xml files, that way, you won't have to recompile your entire application if you want to change it.
2. don't forget to close your connections, ...
3. print the stacktrace when an exception is caught, you'll have more info about what is going wrong and where it's going wrong. (somehow, based on the above code, your output comes from your catch block, but not really sure ... )

also not sure about this:
user=root&password="
might be he's expecting something for password, even if it's only an empty String

well, you're trying to read from the resultset (on line 10) before you've progressed the pointer to the first record, which is what's causing that error.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.