jsp问题,显示接口Connection和PreparedStatement不能作为type,是不是要包含什么东西进去,我刚开始学jsp

[复制链接]
查看11 | 回复1 | 2011-5-19 12:50:27 | 显示全部楼层 |阅读模式
%
        booleanboo=false;
        Stringm=\"\";/*信息提示*/
        if(userid.getName()=null){
                m=\"请输入用户名!\";
                boo=false;
        }
        if(userid.getName()!=null){
                Connectioncon=null;
                try{
                        Class.forName(\"oracle.jdbc.driver.OracleDriver\");
                }catch(ClassNotFoundExceptione){}/*异常处理*/
                try{
                        con=DriverManager.getConnection(\"jdbc:odbc:user\",\"user\",\"user\");
                        Stringstr=\"insertintouservalues(?,?,?,?)\";
                        PreparedStatementpstmt=con.prepareStatement(str);
                        pstmt.setString(1,userid.getName());
                        pstmt.setString(2,userid.getName());
                        pstmt.setString(3,userid.getPhone());
                        pstmt.setString(4,userid.getEmail());
                        pstmt.execute();
                        pstmt.close();
                        con.close();
                        m=\"用户注册成功\";
                        boo=true;
                }catch(Exceptione){
                        m=\"插入数据时出错\";
                        boo=false;
                }
        }
%
回复

使用道具 举报

千问 | 2011-5-19 12:50:27 | 显示全部楼层
你忘记导入sql相关类的包了。
再网页的最上面加上这句就可以了。
%@pageimport=\"java.sql.*\"%
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行