楼主应该是用 jdbc来测试吧,请去检查是否有这样的代码:
conn.setReadOnly(true);
这个就会造成只能读取,无法插入。
另外,编码的问题只会在涉及中文字符和数据库交互的时候才会有问题,一般来说,做到以下就可以解决中文的正常了:
在页面上charset,数据库的字符集,服务器的字符集,都统一就可以了,一般来说选择utf-8

解决方案 »

  1.   

    String sql="insert into table (字段1,字段2)  value (value1,value2)";resultset=satatemnet.executeQuery(sql);
      

  2.   

    要设置conn.setReadOnly(false); 
      

  3.   

    还是不行啊!我都改了.
    其中数据库 设置为utf-8. 
    连接语句为 
    private String url = "jdbc:mysql://localhost:3306/db_shopping?useUnicode=true&characterEncoding=utf-8"; 
    和connection.setReadOnly(false); 网页中有语句<%@ page contentType="text/html; charset=utf-8"%>和<meta http-equiv="Content-Type" content="text/html; charset=utf-8">有如下函数public class Chinese {  public static String toUnicode(String strvalue) {
        try {
          if (strvalue == null) {
            return null;
          }
          else {
            strvalue = new String(strvalue.getBytes("utf-8"), "ISO8859_1");
            return strvalue;
          }
        }
        catch (Exception e) {
          return "";
        }
      }  public static String toChinese(String strvalue) {
        try {
          if (strvalue == null) {
            return "";
          }
          else {
            strvalue = new String(strvalue.getBytes("ISO8859_1"), "utf-8");
            return strvalue;
          }
        }
        catch (Exception e) {
          return "";
        }
      }
    还是不能插入啊,在数据先填数据再查询时,中文乱码!!跪求高手指点了啊...
      

  4.   

    那你抛开web层,你去数据库里看看,到底是什么编码?
    问题一个一个来 ,你现在有2文件,乱码和无法新增,一个一个解决
      

  5.   

     有吧..因为有如下语句啊.
    private String dbDriver = "com.mysql.jdbc.Driver";
      private String url = "jdbc:mysql://localhost:3306/db_shopping?useUnicode=true&amp;characterEncoding=utf-8";
      public Connection connection = null;
      public JDBConnection() {
        try {
          Class.forName(dbDriver).newInstance(); //加载数据库驱动
          connection = DriverManager.getConnection(url, "root", "123"); //加载数据库
          connection.setReadOnly(false); 
        }
        catch (Exception ex) {
          System.out.println("数据库加载失败");
        }
      }