Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JDBC,SQL and DataBases(oh my!)

Options
  • 15-01-2003 11:50am
    #1
    Closed Accounts Posts: 1,719 ✭✭✭


    ok,
    i have a few questions with some general relation to the topics of SQL,JDBC and other nasty things :p

    so to start, i have a class that i'm using to devolop a little JDBC app,now i want to pass a String to it,and then convert the String to a Statement. i have no idea how to do this,as i cant cast it. it there a method to convert one to the other? and vice-versa?

    Also can anyone recommend a good XML parser (written in java)

    thanks


Comments

  • Registered Users Posts: 1,186 ✭✭✭davej


    If I understand correctly, what you're asking is a very basic question about java and databases....

    You don't convert a String to a Statement:

    String sql = "select * from table";
    Statement st =con.createStatement(); // con is your Connection
    ResultSet rs = st.executeQuery(sql);
    while (rs.next()){

    //do stuff here

    }


    As you can see the string is passed to the Statement by the executeQuery(String sql) method. You should check out one of the many beginners tutorials on java and databases/sql out there on the web.

    Xerces is the apache xml parser....probably a good bet

    davej


  • Registered Users Posts: 932 ✭✭✭yossarin


    also useful are prepared statements:


    On JGuru


  • Closed Accounts Posts: 1,719 ✭✭✭Ruaidhri


    thanks davej (doh! did not think of that)
    i'll go check out xeres.


  • Moderators, Motoring & Transport Moderators, Technology & Internet Moderators Posts: 22,668 Mod ✭✭✭✭bk


    Originally posted by Ruaidhri

    Also can anyone recommend a good XML parser (written in java)

    thanks

    Java 1.4 and greater comes with an XML parser as standard. You can find info about it here
    http://java.sun.com/j2se/1.4/docs/guide/xml/


Advertisement