?
Solved

java.sql.SQLException: General error

Posted on 2003-11-23
9
Medium Priority
?
1,209 Views
Last Modified: 2007-12-19
i have this error.

java.sql.SQLException: General error
        at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6987)
        at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
        at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3150)
        at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:214)
        at beans.customer.insert(customer.java:98)
        at org.apache.jsp.customer_0005fconfirm$jsp._jspService(customer_0005fconfirm$jsp.java:150)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

and this is the code.

       public void getConnection() throws SQLException, ClassNotFoundException {
           try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               conn = DriverManager.getConnection("jdbc:odbc:myDSN");
           } catch (Exception e) { e.printStackTrace(); }
        }
     
        public void insert() {
            try {
            getConnection();
            PreparedStatement pstmt=null;
            pstmt=conn.prepareStatement("insert into Customer values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
            pstmt.setString(1, customer );
            pstmt.setString(2, customercode );
            pstmt.setString(3, warranty );
            pstmt.setString(4, ic );
            pstmt.setString(5, addr1 );
            pstmt.setString(6, addr2 );
            pstmt.setString(7, addr3 );
            pstmt.setString(8, postcode );
            pstmt.setString(9, state );
            pstmt.setString(10, area  );
            pstmt.setString(11, tel );
            pstmt.setString(12, handphone );
            pstmt.setString(13, dob );
            pstmt.setString(14, dop );
            pstmt.setString(15, dealer );
            pstmt.setString(16, status );
            pstmt.setString(17, remark);
            pstmt.setString(18, operator );
            pstmt.setString(19, date );
            pstmt.execute();
            }catch (Exception e) {
                e.printStackTrace();
            }
        }

customer.java:98 is pointing to this line,
       pstmt.execute();

Can you tell me what is going on? I am using the ODBC-JDBC bridge. This is setting is done using the XP Profesional ODBC admnistrative task.
What is the "General Error" means? I am sure it's npt general for me.. Ha... :-)
0
Comment
Question by:heman7719
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 580 total points
ID: 9808422
is conn object is created at class level?
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9808426
i doubt this statement also


pstmt=conn.prepareStatement("insert into Customer values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");

should be some thing like this

pstmt=conn.prepareStatement("insert into Customer (customer,costomercode,... ) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");


because table should containg only 19 columns when you follow your procedure
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9808440
is it possible to post your table structure?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:heman7719
ID: 9809125
sudhakar, thank you for your time.

1. conn obeject was created at the beginning of my class. :-)
2. the prepared statement means i am creating the whole DB schema at one shoot. in my db, i have totally 19 fields. then i mean, foloow by the sequence, i insert it one by one.
3. During my design of the db, i set no one as a primary key. i doubt this is the one who causing me this problem.

By the way, what is the General Errors means for me? Is this general consist of what kind of error? Null Pointer? or data truncation?? etc..??
0
 

Author Comment

by:heman7719
ID: 9809138
and one funny things is i still can insert data into my table. I mean the insert() statement.....

but the error come out... what is happening?

0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9809703
Ok can u do some thing like this and let me know?

(customer,customerid,....) values(...,...,...,...,) bla bla bla

i doubt here if we use all columns at a time

0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9809708
>>i doubt here if we use all columns at a time

i mean  without specifying column names
0
 
LVL 3

Expert Comment

by:savalou
ID: 9811125
Try a pstmt.executeUpdate() rather than just an execute().
0
 

Author Comment

by:heman7719
ID: 9822491
sudhakar_koundinya , sovled the problem.

It's beause on my Access database, i specified a field whereby is Primary key and i update a reduntant data for that fields... prompt me error..

thank you for your time.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out the latest tech news, community articles, and expert highlights in August's newsletter.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question