本人在weblogic下调试关于JSP调用usebean的测试程序,有如下错误提示,请指教问题出在那?
错误提示如下:
①"the character  '-' in the name of this file cannot appear in the java identifier."
②"the package of this type does not match its location on the source path:WEB.classes.com.
ydh."
③Type com.ydh.sqlconn contains no methods with this name.

解决方案 »

  1.   

    源程序如下(StudentManager是测试程序项目名称,程序在StudentManager\WEB-INF\classes\com\ydh目录下): 
    package com.ydh;   
     错误①"the character  '-' in the name of this file cannot appear in the java identifier."import java.io.*;
    import java.sql.*;
    public class sqlconn    
    错误②"the package of this type does not match its location on the source path:WEB.classes.com.
    ydh."

    public ResultSet executeQuery(String strsql)
    {
       String user = "sa";
       String password = "";
       String url="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\培训中心\\jakarta-tomcat-5.5.9\\jakarta-tomcat-5.5.9\\webapps\\data\\test\\StudentManger.mdb";
       Connection connect = null;
       ResultSet rs = null;}
    }
      

  2.   

    testSQL.jsp引用程序(程序在StudentManager\目录下)如下:
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <jsp:useBean id="dbBean" scope="page" class="com.ydh.sqlconn"/>  
    错误③Type com.ydh.sqlconn contains no methods with this name.<netui:html>
        <head>    </head>
        <body> <%
    Connection con1=dbBean.getConnection();
    Statement  stmt1=con1.createStatement();
            ResultSet  rs1=null;      
    String sql1="select * from db_student";
    rs1=stmt1.executeQuery(sql1);
    while(rs1!=null&&rs1.next()){
    String s_name=rs1.getString("showname");
    String s_all=rs1.getString("columname");
    System.out.println(s_name);
            }
           
    %>
        </body>
    </netui:html>