Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8241271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:46:56+00:00 2026-06-07T20:46:56+00:00

i have started the java and just completed core java …but i am not

  • 0

i have started the java and just completed core java …but i am not able to proceed further because of the sqlException..
i have load the driver successfully and want to execute the query …but every time i found Exception how can i get rid of this problem…..

my code is as follows:

if(e.getSource()==b1)
    {
        if(t1.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null,"provide username to login");
            t1.requestFocus();
        }
        else if(t2.getText().equals(""))
        {
            JOptionPane.showMessageDialog(null,"provide password to login");
            t2.requestFocus();
        }
        else 
        {
            String tablename=null;
            if(rb==1)
            {tablename="Admin";}
            else if(rb==2)
            {tablename="Clerks";}
            else if(rb==3)
            {tablename="members";}
                try
                {
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    Connection con=DriverManager.getConnection("Jdbc:Odbc:librarysystem","","");
                    PreparedStatement ps=con.prepareStatement("select * from "+tablename+" where username=? and password=?");
                    ps.setString(1,t1.getText());
                    ps.setString(2,t2.getText());
                    ResultSet rs=ps.executeQuery();
                    if(rs.next())
                    {
                        //System.out.println(res);
                        //JOptionPane.showMessageDialog(new JFrame(),"Registered user successful");
                        l=new library();
                    }
                    else
                    {
                        JOptionPane.showMessageDialog(new JFrame(),"wrong details entered");
                    }
                }
                catch(Exception sql)
                {

                    t1.setText ("");
                    t2.setText ("");
                    t1.requestFocus ();
                    System.out.println(sql);
                    JOptionPane.showMessageDialog (null, "Incorrect excep Information Provided.");
                }
        }
    }
    else if(e.getSource()==jrb1)
    {
        rb=1;
    }
    else if(e.getSource()==jrb2)
    {
        rb=2;
    }
    else if(e.getSource()==jrb3)
    {
        rb=3;
    }
    else if(e.getSource()==b2)
    {
        f.setVisible(false);
        f.dispose();
        System.exit(152);
    }   

this always shows : SQLException[Microsoft][ODBC Driver Manager] Invalid string or buffer length

plz help me..fnds

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:46:58+00:00Added an answer on June 7, 2026 at 8:46 pm

    It could be caused by a zero length string as your sql login:

    Connection con=DriverManager.getConnection(“Jdbc:Odbc:librarysystem”,”sa”,”sa_password”);

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started learning Java and have come across a little quirk I'm not
I have just started MongoDB + Java, and I am getting into queries, collections
I have just started leaning and working on xquery with java. I have a
I have just started with java development using Eclipse, when I was debugging this
I've just started using Java EE recently to build webservices. Most of these have
I've just started Java and we have been asked to produce pong (or a
I have just started learning java and i have about 8 months time. My
I have just started to learn Java and is curious is it any good
I am just starting out learning Java, GAE etc. I have started a project
I just have started to program with java rmi and I face the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.