Solved

java.sql.SQLException: General error

Posted on 2003-11-23
9
1,073 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
  • 5
  • 3
9 Comments
 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 145 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now