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

Thread: Problem With JDBC

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Problem With JDBC

    I'm getting an weird error while accessing the database from JDBC driver in JSP using JAVA codes.

    plz help me to find a sollution the program and error details are below.

    <%@ page import="java.sql.*" %>
    <%!
    Statement st;
    Connection con;
    %>
    <%
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbcdbcSN");

    st = con.createStatement();
    ResultSet res = st.executeQuery("SELECT * FROM tbNameOne");
    while(res.next())
    {
    out.println(res.getString(1) + " " + res.getString(2) +"<br>");
    }
    }
    catch(Exception e)
    {
    out.print(e.toString());
    }
    %>
    these codes returns no error while building the project in NetBeans v6.1

    running this file returns me a error message, given below
    java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid string or buffer length
    In the ODBC Data Source, i have added the DSN correctly in both the tabs (user DSN and system DSN, in case i was added in the wrong tab, to be on the safe side i added on both of them). SS are below.




    I am Using:
    OS: Windows 7 RC
    Database: Microsoft SQL Server 2000
    IDE: NetBeans v6.1 (Server Apache TomCat)


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Problem With JDBC

    Have a look at Why do I get 80040E57 / 80040E07 errors?

    That should sort you out.

    Enjoy!

    // Json

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem With JDBC

    i'm getting this in line
    con = DriverManager.getConnection("jdbcdbcSN");
    and by the way, i'm not passing insert query.
    so there is no way could over length the string.

    but thanks for the looking.

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Problem With JDBC

    What exactly does your DSN look like, there might be an issue on that one.

    // Json

  5. #5
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem With JDBC

    google it, to know about DSN

  6. #6
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Problem With JDBC

    Would you mind showing me the full stack trace please?

    // Json

  7. #7
    Junior Member
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem With JDBC

    Quote Originally Posted by Json View Post
    Would you mind showing me the full stack trace please?

    // Json
    what do u mean by 'full stack trace' ?
    i have already posted full code, + SS of the DSN + Error code and Error message

    please explain ?

  8. #8
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Problem With JDBC

    I'd like to see more than just the error code/message, I'd like to see the full stack trace and see where the exception is actually being thrown from.

    Cheers!

    // Json

Similar Threads

  1. How to Connect to an Excel Spreadsheet using JDBC in Java
    By JavaPF in forum JDBC and Database Tutorials
    Replies: 14
    Last Post: August 27th, 2013, 12:57 PM
  2. JNDI - JDBC Integration problem
    By rangarajank in forum JDBC & Databases
    Replies: 0
    Last Post: September 29th, 2009, 07:07 AM
  3. JDBC Problem
    By seejay in forum JDBC & Databases
    Replies: 1
    Last Post: September 16th, 2009, 08:55 AM