Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: database connectivity

  1. #1
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default database connectivity

    [



















    package demo5;
    import java.sql.*;
    public class Demo5 {


    public static void main(String[] args) {
    try{

    String Query="select * from student where rollno=2";
    Class.forName("com.mysql.jdbc.Driver");
    try (Connection con = DriverManager.getConnection("jdbc:mysql://localhost/demo5","root","0" )) {
    Statement st=con.createStatement();
    ResultSet rs=st.executeQuery(Query);
    rs.next();
    String sname=rs.getString(2);
    System.out.println(sname);
    }


    }





    catch(Exception ex ){







    }












    ]/[run:
    BUILD SUCCESSFUL (total time: 0 seconds)


    just coming but i made connectivity with mysql but it means i made four table thatis rollno and and name i also pass a string in this query where student rollno=2 but it is just geting executed its not displaying row table y so
    ]

    --- Update ---

    plz help me out frndssssssss


  2. #2
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Angry connectivity problem

    hi frnds i done connnectivity with mysql i written a code of connectivity in netbeans basically i made 4 table in mysql i want yto select one row from the table were rollno=2 dissplay the name but wen i execute the connectivity code it just run build succesfully it wont display the rowwwwwwwwwww y sooooo just executes succesfully wont show table

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: database connectivity

    Threads merged as I presume they are one and the same. You've been asked more than once to follow certain forum etiquette guidelines ( Announcements - What's Wrong With My Code? ) . Please abide by these guidelines: wrap your code in the code tags, stop double posting, proper thread titles, etc...doing so helps you get help, and continued refusal to do so may result in further action taken by the moderator staff.

  4. #4
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: database connectivity

    frnd m new to forum frnd say wats a problem m getting just executed succesfully y not it disolaying atable or row

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: database connectivity

    Quote Originally Posted by AJAY KAMBLE View Post
    frnd m new to forum frnd say wats a problem m getting just executed succesfully y not it disolaying atable or row
    Huh? I would recommend thinking of those reading your posts as compilers - when you constantly use shorthand (and misspelling), things just don't compile (in other words, make sense). Please use proper English grammar if you wish your message to be understood by the widest audience.

  6. #6
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: database connectivity

    sir its connectivity code i written in netbeans but wen i execute it it just run build succesfully it gives y not it display a row of table

  7. #7
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: database connectivity

    Please format your code. For guidelines Please read .

    In your code you have to iterate through the resultset you get on executing the query.
    try this..
    while(rs.next()){
    String sname=rs.getString(2);
    System.out.println(sname);
    }

  8. #8
    Member
    Join Date
    Feb 2014
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: database connectivity

    my database is not connecting u have any idea how to connect aprat frnd

  9. #9
    Member
    Join Date
    Sep 2013
    Posts
    68
    My Mood
    Confused
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default Re: database connectivity

    I didn't get your problem.

    hi frnds i done connnectivity with mysql i written a code of connectivity in netbeans basically i made 4 table in mysql i want yto select one row from the table were rollno=2 dissplay the name but wen i execute the connectivity code it just run build succesfully it wont display the rowwwwwwwwwww y sooooo just executes succesfully wont show table
    .
    are you facing problem in getting the data from resultset?
    or have problem with your database connectivity?

    Paste the full error message that you get while connecting to the database for better clarification.

Similar Threads

  1. Database Connectivity
    By nkr2310 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 16th, 2013, 07:40 AM
  2. dbscan database connectivity
    By navxxxx in forum JDBC & Databases
    Replies: 1
    Last Post: December 14th, 2012, 10:36 AM
  3. Java DataBase Connectivity Problem
    By sahilradotra in forum JDBC & Databases
    Replies: 1
    Last Post: May 8th, 2012, 07:46 AM
  4. access database connectivity from outside an application
    By suchirag in forum JDBC & Databases
    Replies: 0
    Last Post: October 29th, 2009, 02:03 AM
  5. Database connectivity problem-Oracle
    By Entrant in forum JDBC & Databases
    Replies: 3
    Last Post: October 11th, 2009, 10:08 AM