Solved

JDBC Transaction Problem

Posted on 2004-10-10
1
465 Views
Last Modified: 2008-01-09
I got the following error message when I trying to insert a row to database.
[Microsoft][SQLServer 2000 Driver for JDBC]Can't start a cloned connection while in manual transaction mode.
Here is my code:
 Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
        Connection dbConn=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.121:1433;SelectMode=cursor;DatabaseName=MyDb",strDbUser,strDbPassword);
        Statement stmt=dbConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
        dbConn.setAutoCommit(false);
        ResultSet rs=stmt.executeQuery("Select * from User_Table");
 rs.moveToInsertRow();
        rs.updateObject("userName","hello");
        rs.updateObject("UserLogName","hello");
        rs.updateObject("UserLogPWD","123456");
        rs.updateObject("UserStatus",new Integer(0));
        rs.updateObject("UserPendingPoints",new Integer(0));
        rs.updateObject("UserAwardedPoints",new Integer(0));
        rs.updateObject("UserTotalPoints",new Integer(0));
        rs.updateObject("UserEmail",new String("strUserEmail"));
        rs.updateObject("UserName",new String("strUserName"));
        rs.updateObject("UserLogPWD",new String("strUserPwd"));
        rs.updateObject("UserLogName",new String("strUserLogName")) ;
        rs.updateObject("UserAddress",new String("strUserAddress"));
        rs.updateObject("UserPhone",new String  ("strUserPhone"));
        rs.updateObject("UserMobile",new String("strUserMobile"));
        rs.insertRow();  
        dbConn.commit();  

Can anyone tell me how can I solve the problem?

thank you very much
0
Comment
Question by:cstsang
1 Comment
 
LVL 1

Accepted Solution

by:
schubemk earned 100 total points
ID: 12286138
In your dbconn= statement, you entered "SelectMode=cursor", it should be "SelectMethod=cursor" like this:

dbConn=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.121:1433;SelectMethod=cursor;DatabaseName=MyDb",strDbUser,strDbPassword);
0

Featured Post

What Is Threat Intelligence?

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

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
web service Rest Client creation 4 73
EJB MDB example 4 77
maven webservice projet error 6 79
maven j2ee examles 2 43
Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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