mybatis日志更新系统时间成功,但数据库数据没有变的bug记录

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u012817635/article/details/96151830

1、问题描述

日志中business_date为2019-07-25,但更新到数据库之后,却是2019-07-24

生产环境存在问题,测试环境不存在。生产环境百分百复现。

2、问题排查

经过多次排查之后,发现2019-07-25 13:00:01新就是2019-07-25,2019-07-25 12:59:59就是2019-07-24

找到规律后,基本确认是时区问题,查看测试和生产数据库的时区,果然如此。

测试库时区

生产库时区

生产库是美国时区,而测试库是中国时区,导致了13个小时的误差。

https://www.csdn.net/gather_24/MtTaIg2sMjg4MC1ibG9n.html

最后根据上面博客,指定了时区,解决了问题

展开阅读全文

sqlite3更新数据库问题 SQL执行成功数据库数据不改变

09-05

数据库打开 执行SQL一切正常 但是就是数据库的字段不更新 擦了!找了好久,求大神们看看!!!rnrn if ([self openDB]) rn rn //char *errormsg;rn sqlite3_stmt *statement;//这相当一个容器,放转化OK的sql语句rn NSString *updateSql = [NSString stringWithFormat:@"UPDATE Character SET CH_IsLook = 1 WHERE id = %i",studyId];rn const char *sql = [updateSql UTF8String];rn //sqlite3_exec(_database, "BEGIN TRANSACTION", NULL, NULL, &errormsg);rn int success = sqlite3_prepare_v2(_database, sql, -1, &statement, NULL);rn rn if(success != SQLITE_OK)rn rn MyLog(@"更新数据库错误");rn sqlite3_close(_database);rn return NO;rn rn //sqlite3_bind_int(statement, 1, studyId);rn //执行SQL语句。这里是更新数据库rn success = sqlite3_step(statement);rn rn //sqlite3_exec(_database, "COMMIT", NULL, NULL, &errormsg);rn rn //如果执行失败rn if (success == SQLITE_ERROR) rn NSLog(@"Error: 更新数据库错误");rn //关闭数据库rn sqlite3_close(_database);rn return NO;rn rn //释放statementrn sqlite3_finalize(statement);rn //执行成功后依然要关闭数据库rn sqlite3_close(_database);rn return YES;rn rnrn打印出的SQL在数据库执行时可以的,是不是上面调用执行更新额方法不对???rn2014-09-05 11:27:40.903[7836:60b] 0rn(lldb) po sqlrn"UPDATE Character SET CH_IsLook = 1 WHERE id = 1"rnrn返回的执行码是 101 我对了一下 是说SQL执行成功了啊 论坛

急啊!!!!!!!!!为什么更新数据库后,但是数据库里面的仍然没有变\

04-17

class SelfModel extends AbstractTableModel rn rn private Vector vector1 = new Vector(),vector2 = new Vector(); rn ResultSet rs; rn public SelfModel() rn rn Vector v; rn vector2.add("职工编号"); rn vector2.add("姓名"); rn vector2.add("性别"); rn vector2.add("工资"); rn rs = new DataProcess("Message","Select * From Person").deal(); rn try rn while (rs.next()) rn rn v = new Vector(); rn v.add(rs.getString("ID")); rn v.add(rs.getString("NAME")); rn v.add(rs.getString("SEX")); rn v.add(rs.getString("SALARY")); rn vector1.add(v); rn rn catch(Exception e) e.printStackTrace(); rn rn rn public int getRowCount() rn rn return vector1.size(); rn rn public int getColumnCount() rn rn return vector2.size(); rn rn public String getColumnName(int col) rn rn return (String)vector2.get(col); rn rnrn public Object getValueAt(int row, int column) rn rn return ((Vector)vector1.get(row)).get(column); rn rn rnclass ManagerClassSub2 extends JPanel implements ActionListener//管理员工的工资 rn rn private JPanel jp1,jp2; rn private JLabel jl1,jl2,jl3,jl4; rn private JButton jb1,jb2,jb3; rn private JTextField jtf1,jtf2,jtf3,jtf4; rn private JTable jtb; rn private JScrollPane jsp; rn public ManagerClassSub2() rn rn this.setLayout(null); rn jp1 = new JPanel(); rn jp1.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.red,Color.gray)); rn jp2 = new JPanel(); rn jp2.setBorder(BorderFactory.createTitledBorder("查询结果")); rn jp1.setBounds(0,0,500,100); rn jp2.setBounds(0,100,500,400); rn jp1.setLayout(null); rn jp2.setLayout(null); rn jl1 = new JLabel("职工编号:"); rn jl2 = new JLabel("姓名:"); rn jl4 = new JLabel("工资:"); rn jl3 = new JLabel("性别:"); rn jtf1 = new JTextField(); rn jtf2 = new JTextField(); rn jtf3 = new JTextField(); rn jtf4 = new JTextField(); rn jtf1.setEditable(false); rn jtf2.setEditable(false); rn jtf3.setEditable(false); rn jl1.setBounds(10,20,70,20); rn jtf1.setBounds(85,20,50,20); rn jl2.setBounds(200,20,70,20); rn jtf2.setBounds(280,20,100,20); rn jl3.setBounds(10,50,80,20); rn jtf3.setBounds(85,50,40,20); rn jl4.setBounds(200,50,70,20); rn jtf4.setBounds(280,50,80,20); rn jp1.add(jl1); rn jp1.add(jtf1); rn jp1.add(jl2); rn jp1.add(jtf2); rn jp1.add(jl3); rn jp1.add(jtf3); rn jp1.add(jl4); rn jp1.add(jtf4); rn SelfModel self = new SelfModel(); rn jtb= new JTable(self); rn jtb.setBackground(Color.ORANGE); rn jtb.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); rn jtb.addMouseListener(new MouseAdapter() rn rn public void mouseClicked(MouseEvent e) rn rn rn jtf1.setText(new String().valueOf(jtb.getValueAt(jtb.getSelectedRow(),0))); rn jtf2.setText(new String().valueOf(jtb.getValueAt(jtb.getSelectedRow(),1))); rn jtf3.setText(new String().valueOf(jtb.getValueAt(jtb.getSelectedRow(),2))); rn jtf4.setText(new String().valueOf(jtb.getValueAt(jtb.getSelectedRow(),3))); rn rn ); rn jsp = new JScrollPane(jtb); rn jsp.setBounds(0,20,350,350); rn jb1 = new JButton("查询"); rn jb2 = new JButton("输入"); rn jb3 = new JButton("查看工资分布图"); rn jb1.addActionListener(this); rn jb2.addActionListener(this); rn jb3.addActionListener(this); rn jb1.setBounds(360,20,100,25); rn jb2.setBounds(360,55,100,25); rn jb3.setBounds(360,90,100,25); rn jp2.add(jsp); rn jp2.add(jb1); rn jp2.add(jb2); rn jp2.add(jb3); rn add(jp1,this); rn add(jp2,this); rn rn public void actionPerformed(ActionEvent e) rn rn if(e.getSource()==jb1) rn rn if(e.getSource()==jb2) rn rn try rn Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); rn [color=#FF0000] Connection cnn =DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.6:1433;databasename=Message","sa","112233"); rn PreparedStatement pstmt = cnn.prepareStatement("UPDATE Person SET SALARY=? WHERE NAME=?"); rn System.out.println(jtf1.getText()+jtf4.getText()); rn pstmt.setString(1,jtf4.getText()); rn pstmt.setString(2,jtf1.getText()); rn pstmt.executeUpdate(); rn pstmt.close(); rn cnn.close(); [/color]rn catch(Exception xe)xe.printStackTrace(); rn System.out.println("fsdfsfsdfsdfsdf"); rn if(e.getSource()==jb3) rn rn Dialog dialog = new Dialog(TestDemo.jf,"工资分布图表",true); rn dialog.addWindowListener( rn new WindowAdapter() rn rn public void windowClosing(WindowEvent e) rn rn e.getWindow().setVisible(false); rn e.getWindow().dispose(); rn rn rn ); rn dialog.add(new Matlab()); rn dialog.setSize(400,400); rn dialog.setLocation(200,200); rn dialog.setVisible(true); rn rn rn rnrn 论坛

调用更新数据库记录的存储过程,但数据库记录却不更新(40分)

01-31

问题描述:rnC#调用更新数据库记录的存储过程,但数据库记录却不更新rnrn.CS更新代码如下:rnSqlConnection mySqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionSqlServer"]); rnSqlCommand mySqlCommand = new SqlCommand("Yp_AdminProduct_Update", mySqlConnection);rnmySqlCommand.CommandType = CommandType.StoredProcedure;rnmySqlCommand.Parameters.AddWithValue("@ProductID", ProductID);rnmySqlCommand.Parameters.AddWithValue("@ProBigSortID", iProBigSortID);rnmySqlCommand.Parameters.AddWithValue("@ProSmallSortID", iProSmallSortID);rnmySqlCommand.Parameters.AddWithValue("@ProvinceID", iProvinceID);rnmySqlCommand.Parameters.AddWithValue("@DrugstoreID", iDrugstoreID);rnmySqlCommand.Parameters.AddWithValue("@CurrencyName", sCurrencyName);rnmySqlCommand.Parameters.AddWithValue("@Preparation", sPreparation);rnmySqlCommand.Parameters.AddWithValue("@BusinessMan", sBusinessMan);rnmySqlCommand.Parameters.AddWithValue("@ProImage", sProImage);rnmySqlCommand.Parameters.AddWithValue("@ProInfo", sProInfo);rnmySqlCommand.Parameters.AddWithValue("@Medicare", iMedicare);rnmySqlCommand.Parameters.AddWithValue("@UseCardPlace", sUseCardPlace);rnmySqlCommand.Parameters.AddWithValue("@WarNumber", sWarNumber);rnmySqlCommand.Parameters.AddWithValue("@ViePrice", iViePrice);rntryrnrnmySqlConnection.Open();rnmySqlCommand.ExecuteReader();rnmySqlConnection.Close();rnResponse.Write(@" ");rnrncatch (Exception ex)rnrnResponse.Write("数据库错误,错误原因:" + ex.Message);rnResponse.End();rnrnfinallyrnrnmySqlConnection.Close();rnrnrnrn存储过程如下:rnrncreate procedure Yp_AdminProduct_Update rn(@ProductID varchar(1000),rn@ProBigSortID varchar(1000),rn@ProSmallSortID varchar(1000),rn@ProvinceID varchar(1000),rn@DrugstoreID varchar(1000),rn@CurrencyName varchar(1000),rn@Preparation varchar(1000),rn@BusinessMan varchar(1000),rn@ProImage varchar(1000),rn@ProInfo text,rn@Medicare varchar(1000),rn@UseCardPlace varchar(1000),rn@WarNumber varchar(1000),rn@ViePrice varchar(1000))rnASrnset nocount onrnupdate Yp_Products rnset rniProBigSortID=@ProBigSortID,rniProSmallSortID=@ProSmallSortID,rniProvinceID=@ProvinceID,rniDrugstoreID=@DrugstoreID,rnsCurrencyName=@CurrencyName,rnsPreparation=@Preparation,rnsBusinessMan=@BusinessMan,rnsProImage=@ProImage,rnsProInfo=@ProInfo,rniMedicare=@Medicare,rnsUseCardPlace=@UseCardPlace,rnsWarNumber=@WarNumber,rniViePrice=@ViePrice rnwhere rniProducts_ID = @ProductIDrnset nocount offrn 论坛

没有更多推荐了,返回首页