项目中用到数据库,对数据库不是很了解,现在用mysql数据库,向其中插入数据,然后通过数据浏览器查看表,发现并没有及时更新,怎么解决?

解决方案 »

  1.   

    你是如何插入数据的? 事务是否打开了? 有没有进行提交 commit;
      

  2.   

    直接在sql编辑器中写sql语句的
    如INSERT into table_currentday(cityID, cityName, date_Solar, date_Lunar, weather, temperature, wind)
    VALUES(123456, '','', '','', '','')
      

  3.   

    还有个问题,关于sql语句的先贴上部分代码 public void updataDB(String strTableName,
    int strCityID,
    String strCityName,
    String strDate_Solar,
    String strDate_Lunar,
    String strWeather,
    String strTemperature,
    String strWind) {
    this.initConnection(); //初始化数据库连接
    try {
    //声明SQL语句
    Statement stmt = conn.createStatement();
    String sql = "INSERT into '%" + strTableName + "%'" + "(cityID, cityName, date_Solar, date_Lunar, weather, temperature, wind)"
    + "VALUES( '%" + strCityID + "%','%" +strCityName  + "%','%" 
    + strDate_Solar  + "%','%" + strDate_Lunar + "%','%"
    + strWeather + "%','%" + strTemperature + ",'%"
    + strWind + "%')";
    stmt.execute(sql);
    } catch(Exception e) {
    e.printStackTrace();
    } finally {
    this.closeConnection();
    }
    }
    %'和'%到底该怎么用?我的这个sql语句老是报错,请高手看看该怎么改,谢谢了!