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 6 of 6

Thread: JDBC errors

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    9
    My Mood
    Angelic
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JDBC errors

    import java.io.*;
    import java.util.*;
    import java.sql.*;
    class empListCondition {
    @SuppressWarnings("deprecation")
    public static void main(String[] args)throws Exception
    {
    DataInputStream dis=new DataInputStream(System.in);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbcdbc:jeevandb","SYSTEM","g1");
    Statement st=con.createStatement();
    //------condition 1---------
    System.out.println("enter the toon letter");
    char let=(char)dis.read();
    /*System.out.println("enter the salary");
    int sal=Integer.parseInt(dis.readLine());*/
    ResultSet rs=st.executeQuery("select * from toonlist where toon[0]="+let);
    System.out.println("toons are"+rs);
    rs.close();
    st.close();
    con.close();

    }
    }
    ##################################
    following are the runtime errors i am getting..please help me
    ####################################

    Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC SQL Server Dr
    iver][DBNETLIB]SQL Server does not exist or access denied.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknow n Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at empListCondition.main(empListCondition.java:10)


  2. #2
    Member
    Join Date
    Dec 2011
    Posts
    50
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default Re: JDBC errors

    Check your server's connection settings, possibly wrong database name/username/password.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    9
    My Mood
    Angelic
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JDBC errors

    thx nickyc last time it was due to incompatibility with my 64 bit lap. i have dwnlded latest 11g R2 . now its fine and i am on to it... thx

  4. #4
    Junior Member
    Join Date
    Dec 2011
    Posts
    9
    My Mood
    Angelic
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JDBC errors

    import java.io.*;
    import java.util.*;
    import java.sql.*;
    class empListCondition {
    @SuppressWarnings("deprecation")
    public static void main(String[] args)throws SQLException,IOException,ClassNotFoundException
    {
    DataInputStream dis=new DataInputStream(System.in);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbcdbc:jeevan_db","system","Passpass1");
    Statement st=con.createStatement();
    //------condition 1---------
    System.out.println("enter eno");
    int no=Integer.parseInt(dis.readLine());
    ResultSet rs=st.executeQuery("select ename,esal from emp where eno="+no);
    System.out.println("details are"+rs.getString("ename"));
    rs.close();
    st.close();
    con.close();

    }
    }
    ################################################## #
    this time i installed 11g R2 and connection got established and still following are the run time errors i am facing!!!
    ################################################## #
    my table is: create table emp(eno number(5),ename varchar2(10),esal number(10));
    ################################################## #
    i inserted : insert into emp values(1,'jeevan',100);
    insert into emp values(2,'jeevan1',1000);
    C:\Users\Wade\Desktop\javaprogs>java empListCondition
    enter eno
    2
    Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manage
    r] Invalid cursor state
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unkn own Source)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
    at empListCondition.main(empListCondition.java:16)
    ################################################## #####
    god help me please guys
    Last edited by jeevan reddy mandali; January 9th, 2012 at 02:54 AM.

  5. #5
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: JDBC errors

    System.out.println("details are"+rs.getString("ename"));
    Can not find ename in the result set.

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

    Default Re: JDBC errors

    @jeevan reddy mandali, I think you have broken quite a few forum rules and etiquette with this one question (I call it a question although I fail to see one in your posts) - read the forum rules. I am locking your other post. Continue to break the rules and further action will be taken

    http://www.javaprogrammingforums.com...sor-state.html

Similar Threads

  1. JDBC Problem - com.mysql.jdbc.Driver
    By icu222much in forum Java Servlet
    Replies: 2
    Last Post: November 21st, 2011, 11:54 PM
  2. help with errors
    By hello_world in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 9th, 2011, 09:11 PM
  3. Can't fix my own errors
    By mrroberts2u in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 14th, 2011, 09:20 AM
  4. Many Errors
    By Woody619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 16th, 2010, 09:36 PM
  5. Getting errors
    By Nonire in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 4th, 2010, 12:21 PM

Tags for this Thread