Chinaunix

标题: 求教:jsp在Oracle中的错误 [打印本页]

作者: michaelwon    时间: 2004-07-21 12:49
标题: 求教:jsp在Oracle中的错误
出现
java.sql.SQLException: No suitable driver
该如何解决呢
请教了
作者: renxiao2003    时间: 2004-07-21 19:45
标题: 求教:jsp在Oracle中的错误
没有正确指定驱动程序所在的位置,或者驱动程序版本不对!
作者: michaelwon    时间: 2004-07-21 19:56
标题: 求教:jsp在Oracle中的错误
我把oracle 9i的jdbc驱动都加到classpath中了,
我用的是 Tomcat+Oracle 9i + jsp in windows 2000 server
在Tomcat中的配置文件还有加Oracle中的什么吗?(静态的网站没有问题)

<%@ page contentType="text/html;charset=GB2312"%>;
<%@ page import="java.sql.*"%>;
<html>;
<body>;
<%
        Connection con=null;
        Statement sql=null;
        ResultSet rs=null;
       
        try
        {
                Class.forName("oracle.jdbc.driver.OracleDriver";
        }
        catch(ClassNotFoundException e){ }
       
        try
        {

            String url = "jdbcracle:thin192.168.1.177:1521ukouhin";
            String userName = "scott";
                   String password = "tiger";
                  
                  
                   con=DriverManager.getConnection (url, userName, password);
                  
                sql=con.createStatement();
                rs=sql.executeQuery("select * from emp";
                out.print("<Table Border>;";
                out.print("<tr>;";
                        out.print("<th width=100>;"+"empno";
                        out.print("<th width=50>;"+"ename";
                out.print("</tr>;";
                while(rs.next())
                {
                        out.print("<tr>;";
                                int n=rs.getInt(1);
                                out.print("<td>;"+n+"</td>;";
                                String e=rs.getString(2);
                                out.print("<td>;"+e+"</td>;";
                        out.print("</tr>;");
                }
                out.print("</Table>;");
                con.close();
        }
        catch(SQLException el)
        {
                out.print(""+el);
        }
%>;
</body>;
</html>;




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2