The method getconn() is undefined for the type words

问题描述

为什么我明明定义了方法,还回出现错误??包contorl下有两个类,一个accessdb类,一个words类继承accessdb;而在jsp调用words这个javabean但是出现我没定义方法为什么???accessdb源代码:packagecontrol;importjava.sql.*;publicclassaccessdb{Connectioncon;Statementstmt;ResultSetrs;publicvoidaccessdb(){stmt=null;rs=null;}publicbooleangetconn(){try{Class.forName("sun,jdbc.odbc.JdbcOdbcDriver");con=DriverManager.getConnection("jdbc:odbc:student");returntrue;}catch(SQLExceptionex){System.out.println(ex.toString());returnfalse;}catch(ClassNotFoundExceptionex){System.out.print(ex);returnfalse;}}publicbooleanexeSql(StringstrSql){try{stmt=con.createStatement();stmt.executeUpdate(strSql);returntrue;}catch(Exceptionex){returnfalse;}}publicResultSetexeSqlQuery(StringstrSql){try{stmt=con.createStatement();rs=stmt.executeQuery(strSql);}catch(Exceptionex){System.out.println(ex.toString());rs=null;}returnrs;}publicvoidconclose(){try{con.close();}catch(Exceptionex){System.out.println(ex.toString());}}}jsp页面:<%@pagelanguage="java"contentType="text/html;charset=GB2312"pageEncoding="GB18030"%><%@pageimport="java.sql.*"%><jsp:useBeanclass="control.words"id="words"scope="page"/><html><head><metahttp-equiv="Content-Type"content="text/html;charset=GB2312"><title>Inserttitlehere</title></head><body><%if(words.getconn()){out.println("connectedsuccessfull!");}else{out.println("connectedfaild!");}%></body></html>错误代码:HTTPStatus500---------------------------------------------------------------------------------typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatpreventeditfromfulfillingthisrequest.exceptionorg.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:12inthejspfile:/b.jspThemethodgetconn()isundefinedforthetypewords9:</head>10:<body>11:<%12:if(words.getconn())13:{14:out.println("connectedsuccessfull!");15:}Stacktrace:org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)javax.servlet.http.HttpServlet.service(HttpServlet.java:803)noteThefullstacktraceoftherootcauseisavailableintheApacheTomcat/6.0.10logs.为什么我明明定义了????

解决方案

本帖最后由 hjl317834478 于 2011-01-07 21:37:05 编辑
解决方案二:
你的类为accessdb而你的jsp种<jsp:useBeanclass="control.words"id="words"scope="page"/>你哪来的words类
解决方案三:
<jsp:useBeanclass="control.accessdb"id="words"scope="page"/>

时间: 2025-01-01 07:03:07

The method getconn() is undefined for the type words的相关文章

The method getResources() is undefined for the type

在非activity的独立类(public class readwhatsapp)中调用getResources()时(InputStream is = getResources().openRawResource(R.raw.wa_contacts.db)),出现The method getResources() is undefined for the type 这是因为 getResources() 其实是contex中传递过去的,在非activity类中没有找到可以传递的cavas 解决

The method getSingleResult() is undefined for the type Query

问题描述 关联的代码提取下 QueryResult qr = new QueryResult<T>(); Query query = this.getSession().createQuery("select count(o) from "+entityName+" o " +(wherejpql==null? "": " where "+ wherejpql)); qr.setTotalRecord(query.

The method getTextContent() is undefined for the type Node ?

问题描述 Jdk改成1.6和1.7都没用 解决方案 解决方案二:基本类型long不能为空,用对象类型应该没有问题Long.Integer解决方案三:基本类型long不能为空,用对象类型应该没有问题Long.Integer解决方案四:回错地方了

java sting split- The method sqlit(String) is undefined for the type String

问题描述 The method sqlit(String) is undefined for the type String 小弟新手!!!split()函数以前用的好好地!今天突然直接就报个这么个错误!!看了半天没发现错误!用法跟以前一模一样啊!为什么会报错呢!!导致jsp页面无法编译!传递参数为:&steelmar=YT201%20,%20Ф5.5-Ф20 报错代码String[] ms = electty.sqlit(",");!!!!求高人指点迷津啊!!!!!!!!!!

The method getParmaeter(String) is undefined for the type HttpServletRequest

问题描述 <%@ page pageEncoding="gb2312"%><%@ page contentType="text/html; charset=gb2312" language="java" %><% request.setCharacterEncoding("gb2312");%><%@ page import="java.sql.*" errorPa

ajax-highcharts---XXX.xAxis is undefined求解!!!

问题描述 highcharts---XXX.xAxis is undefined求解!!! 控制台提示错误:XXX.xAxis is undefined 图1 highcharts的初始化) ajax获取图标中数据的方法 控制台提示错误:XXX.xAxis is undefined 解决方案 你的tar_chart实例化过没有,而且xAxis是数组,没有setCatalogories方法 http://www.hcharts.cn/api/index.php#Chart.xAxis 解决方案二:

arrayadapter-The constructor ArrayAdapter&amp;amp;lt;String&amp;amp;gt;is undefined

问题描述 The constructor ArrayAdapter<String>is undefined The constructor ArrayAdapter(XListViewActivity, int, ArrayList) is undefined,向各位大神求解 解决方案 Android错误:方法setListAdapter(ArrayAdapter) is undefined for the type Stringhe method isEmpty() is undefined

imageview-如何访问一个 activity 以外的资源?

问题描述 如何访问一个 activity 以外的资源? 我有下面的代码: Bitmap bMap = BitmapFactory.decodeResource(getResources(), R.drawable.icon); imageView.setImageBitmap(bMap); 但是获得以下的错误: The method getResources() is undefined for the type ImageDownloader 如何访问资源呢? 解决方案 在你的 ImageDo

多线程问题-新手求助关于Java多线程中启动线程问题

问题描述 新手求助关于Java多线程中启动线程问题 public class Example15_1 { /** * @param args */public static void main(String[] args) { // TODO Auto-generated method stub SpeakHello speakHello; SpeakNinhao speakNinhao; speakHello = new SpeakHello(); speakNinhao= new Speak