2017-03-31 71 views
0

作爲標題說我可以從數據庫中讀取但不能插入也不能更新。我檢查了SQL Management,我的用戶可以讀取,寫入,也是數據庫所有者。 (DBO)可以選擇但不能寫入/更新到SQL服務器

進出口使用的MyBatis使用JDBC對微軟SQL Management Studio中

sqlFunctions.InsertIntoUserDatabase(3, "Kar", "LEEE"); 


    public void InsertIntoUserDatabase(int id, String firsname, String lastname) { 
    session = sqlConnection.GetSqlSessionFactory().openSession(); 
    if(CheckIfSessionIsOpen(session)) { 
     Employee employee = new Employee(); 
     employee.setFirstName(firsname); employee.setLastName(lastname); 
     mapper.InsertInUsers(employee); 
    } 
} 

@Insert("INSERT INTO company(firstname,lastname) VALUES(#{firstName}, #{lastName})") 
void InsertInUsers(Employee employee); 

員工是正常的getter和setter(INT ID,字符串名字,絃樂姓氏)

@Results({ 
     @Result(property = "firstName", column = "firstname"), 
     @Result(property = "lastName", column = "lastname") 
}) 

我的SQL連接按原樣打開,並且不顯示錯誤。

回答

0

看來你的交易是隻讀的,這是默認行爲。

您還需要使其可寫,例如

@Transactional(propagation=Propagation.REQUIRED, readOnly=false, rollbackFor=Exception.class) 

問候, 克尚

+0

您好,感謝您的回覆。可悲的是,這不是一個春季項目...... – xDotcom