Solved

java.sql.SQLException: General error

Posted on 2003-11-23
9
1,179 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 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Popular third-party chat platforms like Slack, Discord, and Telegram are just a few of the many new productivity applications that are being hijacked by cybercriminals to create command-and-control (C&C) communications infrastructures for their malw…
Let’s face it: one of the reasons your organization chose a SaaS solution (whether Microsoft Dynamics 365, Netsuite or SAP) is that it is subscription-based. The upkeep is done. Or so you think.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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