• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1277
  • Last Modified:

java.sql.SQLException: General error

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
heman7719
Asked:
heman7719
  • 5
  • 3
1 Solution
 
sudhakar_koundinyaCommented:
is conn object is created at class level?
0
 
sudhakar_koundinyaCommented:
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
 
sudhakar_koundinyaCommented:
is it possible to post your table structure?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
heman7719Author Commented:
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
 
heman7719Author Commented:
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
 
sudhakar_koundinyaCommented:
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
 
sudhakar_koundinyaCommented:
>>i doubt here if we use all columns at a time

i mean  without specifying column names
0
 
savalouCommented:
Try a pstmt.executeUpdate() rather than just an execute().
0
 
heman7719Author Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now