Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

JDBC,SQL and DataBases(oh my!)

  • 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, Registered Users 2 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, Registered Users 2 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: 23,707 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