jsp访问数据库

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:49:59
我把连接数据库的类写在了 connDB.java中 为什么出现这个提示啊????
An error occurred at line: 7 in the generated java file
Only a type can be imported. com.wgh.DB.connDB resolves to a package

An error occurred at line: 4 in the jsp file: /index.jsp
connDB cannot be resolved to a type
1: <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
2: <%@ page import="com.wgh.DB.connDB" %>
3: <%
4: connDB conn=new connDB();
5: String username=(String)session.getAttribute("username");
6: ResultSet rs_sale=conn.executeQuery("select top 2 ID,GoodsName,price,nowprice,picture from tb_goods where sale=1 order by INTime desc");
7: int sale_ID=0;
说什么打包错误 ,怎么解决啊.......

注:原来访问的是2000数据库 后来我改成2005了
类写上:
public class connDB {
public Connection conn = null;
public Statement stmt = null;
public

<%@ page import="com.wgh.DB.connDB" %>
说你这条语句导入的是包,
也就是说你在类中很可能写了package com.wgh.DB.connDB这样的包裹

而不是写package com.wgh.DB
回去检查一下。

com.wgh.DB.connDB ? 我仔细看下你的那个类的包名对吗?你看看有没有别的包中也有connDB 类。注意大小写问题。

import="java.sql.*,..connDB" 是不是你没有导入包的原因啊?

是不是没有添加数据库驱动