JAVA开发犯的细节错误

来源:互联网 发布:魔力宝贝水龙100数据 编辑:程序博客网 时间:2024/05/17 03:46

1.

  Connection conn=null;        Statement statement=null;        try{            conn=dataSource.getConnection();            statement=conn.createStatement();            statement.execute("insert into people (id,name,age,sex) VALUES ("+p.getId()+",'"+p.getName()+"','"+p.getAge()+"','"+p.getSex()+"')");        }        catch (SQLException e){            e.printStackTrace();        }
VALUES 里面的参数如果是字符串,需要在双引号中加入两个单引号;


2.

        String str="路飞.索隆.乌索普";        //String array[]=str.split(".");        String array[]=str.split("\\.");        System.out.println(array[0]+','+array[1]+','+array[2]);
               因为split的参数是正则表达式

0 0
原创粉丝点击