免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1849 | 回复: 9
打印 上一主题 下一主题

sybase链接程序编译通过,移植到JSP的问题(已解决) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-11-27 10:12 |只看该作者 |倒序浏览
一个连接sybase数据库的class在javac编译通过后,执行也成功
但移至jsp后就出错,请问是否配置有问题?

jsp如下:
<%@page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>;
<html>;
<head>;
<title>;Untitled Document</title>;
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">;
</head>;

<body>;

<%
String yhm = request.getParameter("yhm" ;
String yhmm = request.getParameter("yhmm" ;

Connection conn = null;
try
{
        Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
}
catch( java.lang.ClassNotFoundException ae )
{
        System.err.println("ae:" + ae.getMessage());
}
         
String u ="jdbc:sybase:Tds:128.1.1.212:7200";
conn = DriverManager.getConnection(u,"dxpt","123456";
Statement stmt = conn.createStatement();
String query = "Select oper_name,oper_passwd from dx_operator where oper_no=yhm and stat='0'";
ResultSet rs = null;

try
{
             rs = stmt.executeQuery( query );
}
catch(SQLException be)
{
        System.err.println("be.executeQuery:" + be.getMessage());
}
         
String OperName = rs.getString( 1 );
String OperPasswd = rs.getString( 2 );

rs.close();
conn.close();        

if(yhmm.equals(OperPasswd))
{
out.println("欢迎光临";
}
else
{
out.println("密码错";
}
%>;
</body>;
</html>;

执行出错:
Error: 500
Location: /examples/jsp/dxpt/login_in.jsp
Internal Servlet Error:

javax.servlet.ServletException: No suitable driver
        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:460)
        at jsp.dxpt.login_in_6._jspService(login_in_6.java:107)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
        at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
        at org.apache.tomcat.core.Handler.service(Handler.java:235)
        at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
        at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
        at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
        at java.lang.Thread.run(Thread.java:536)
Root cause:
java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getConnection(DriverManager.java:532)
        at java.sql.DriverManager.getConnection(DriverManager.java:171)
        at jsp.dxpt.login_in_6._jspService(login_in_6.java:70)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java)
        at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java:574)
        at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
        at org.apache.tomcat.core.Handler.service(Handler.java:235)
        at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
        at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:917)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:833)
        at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java:176)
        at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:494)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:516)
        at java.lang.Thread.run(Thread.java:536)

              

论坛徽章:
0
2 [报告]
发表于 2003-11-27 10:45 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

you can check the informations below one by one:

If you use a wrong connection url
If your jar file not in WEB-INF/lib

论坛徽章:
0
3 [报告]
发表于 2003-11-27 10:58 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

url 不会错,写成.java文件编译后用java执行都可以

WEB-INF下没有lib目录,我新建了一个再将jconn2d.jar放入后执行依旧

就我~

论坛徽章:
0
4 [报告]
发表于 2003-11-27 11:08 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

你是什么机器?

  1. jdbc:sybase:Tds:128.1.1.212:7200
复制代码


请贴出你的相关系统信息?

论坛徽章:
0
5 [报告]
发表于 2003-11-27 11:09 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

试试这个目录 E:\tomcat\server\lib

该是jconn2.jar文件吧??

论坛徽章:
0
6 [报告]
发表于 2003-11-27 11:10 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

where oper_no=yhm


??

where oper_no='yhm'

论坛徽章:
0
7 [报告]
发表于 2003-11-27 11:11 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

把你work目录生成的相对于这个jsp文件的java文件,给偶们看看.

论坛徽章:
0
8 [报告]
发表于 2003-11-27 11:21 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

数据库在unix的机器上


package jsp.dxpt;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;


public class login_in_1 extends org.apache.jasper.runtime.HttpJspBase {


    static {
    }
    public login_in_1( ) {
    }

    private boolean _jspx_inited = false;

    public final synchronized void _jspx_init() throws org.apache.jasper.JasperException {
        if (! _jspx_inited) {
            _jspx_inited = true;
        }
    }

    public void _jspService(HttpServletRequest request, HttpServletResponse  response)
        throws java.io.IOException, ServletException {

        JspFactory _jspxFactory = null;
        PageContext pageContext = null;
        HttpSession session = null;
        ServletContext application = null;
        ServletConfig config = null;
        JspWriter out = null;
        Object page = this;
        String  _value = null;
        try {
            try {

                _jspx_init();
                _jspxFactory = JspFactory.getDefaultFactory();
                response.setContentType("text/html; charset=gb2312";
                pageContext = _jspxFactory.getPageContext(this, request, response,
                                        "", true, 8192, true);

                application = pageContext.getServletContext();
                config = pageContext.getServletConfig();
                session = pageContext.getSession();
                out = pageContext.getOut();

                // HTML // begin [file="C:\\jakarta-tomcat-3.3.1a\\webapps\\examples\\jsp\\dxpt\\login_in.jsp";from=(0,99);to=(9,0)]
                    out.write("\r\n<html>;\r\n<head>;\r\n<title>;Untitled Document</title>;\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">;\r\n</head>;\r\n\r\n<body>;\r\n\r\n";

                // end
                // begin [file="C:\\jakarta-tomcat-3.3.1a\\webapps\\examples\\jsp\\dxpt\\login_in.jsp";from=(9,2);to=(52,0)]
                    
                    String yhm = request.getParameter("yhm" ;
                    String yhmm = request.getParameter("yhmm" ;
                    
                    Connection conn = null;
                    try
                    {
                            Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" );
                    }
                    catch( java.lang.ClassNotFoundException ae )
                    {
                            System.err.println("ae:" + ae.getMessage());
                    }
                             
                    String u ="jdbc:sybase:Tds:128.1.1.212:7200";
                    conn = DriverManager.getConnection(u,"dxpt","123456";
                    Statement stmt = conn.createStatement();
                    String query = "Select oper_name,oper_passwd from dx_operator where oper_no='yhm' and stat='0'";
                    ResultSet rs = null;
                    
                    try
                    {
                                 rs = stmt.executeQuery( query );
                    }
                    catch(SQLException be)
                    {
                            System.err.println("be.executeQuery:" + be.getMessage());
                    }
                             
                    String OperName = rs.getString( 1 );
                    String OperPasswd = rs.getString( 2 );
                    
                    rs.close();
                    conn.close();        
                    
                    if(yhmm.equals(OperPasswd))
                    {
                    out.println("欢迎光临";
                    }
                    else
                    {
                    out.println("密码错误";
                    }
                // end
                // HTML // begin [file="C:\\jakarta-tomcat-3.3.1a\\webapps\\examples\\jsp\\dxpt\\login_in.jsp";from=(52,2);to=(55,0)]
                    out.write("\r\n</body>;\r\n</html>;\r\n";

                // end

            } catch (Exception ex) {
                if (out != null && out.getBufferSize() != 0)
                    out.clearBuffer();
                if (pageContext != null) pageContext.handlePageException(ex);
            } catch (Error error) {
                throw error;
            } catch (Throwable throwable) {
                throw new ServletException(throwable);
            }
        } finally {
            if (out instanceof org.apache.jasper.runtime.JspWriterImpl) {
                ((org.apache.jasper.runtime.JspWriterImpl)out).flushBuffer();
            }
            if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
        }
    }
}

论坛徽章:
0
9 [报告]
发表于 2003-11-27 11:41 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

Sorry,刚才没用心看.

String query = "Select oper_name,oper_passwd from dx_operator where oper_no='"+yhm+"' and stat='0'";

论坛徽章:
0
10 [报告]
发表于 2003-11-27 12:35 |只看该作者

sybase链接程序编译通过,移植到JSP的问题(已解决)

重启了一下tomcat,行啦!
但还是不知道为什么。
whatever,谢谢各位!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP