问题后续修改hibernate 之后,配置了本机mysql的密码依旧有错误:
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: org.hibernate.exception.SQLGrammarException: could not execute query
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)root cause org.hibernate.exception.SQLGrammarException: could not execute query
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.doList(Loader.java:2148)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.apache.jsp.index_jsp._jspService(index_jsp.java:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause java.sql.SQLException: Table 'bookstore.orders' doesn't exist
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
org.hibernate.loader.Loader.doQuery(Loader.java:662)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.apache.jsp.index_jsp._jspService(index_jsp.java:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
可能是配置的小问题,也可能是原来的WEB中需要修改代码,还望大侠指点,
如果要修改是修改哪些文件的那些部分~!
感谢万分~!!!
HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: org.hibernate.exception.SQLGrammarException: could not execute query
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)root cause org.hibernate.exception.SQLGrammarException: could not execute query
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.doList(Loader.java:2148)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.apache.jsp.index_jsp._jspService(index_jsp.java:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause java.sql.SQLException: Table 'bookstore.orders' doesn't exist
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
org.hibernate.loader.Loader.doQuery(Loader.java:662)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
org.hibernate.loader.Loader.doList(Loader.java:2145)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
org.hibernate.loader.Loader.list(Loader.java:2024)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
org.apache.jsp.index_jsp._jspService(index_jsp.java:151)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
可能是配置的小问题,也可能是原来的WEB中需要修改代码,还望大侠指点,
如果要修改是修改哪些文件的那些部分~!
感谢万分~!!!
解决方案 »
- 很简单的SSH问题 java.lang.NullPointerException 在线等!!!
- java mail 相关问题
- jquery如何遍历service中的list
- 怎么在pdf用插入swf文件?itext或其他框架里具体怎么做?其他语言也可以。
- 能不能帮我看下这个异常应怎么解决?
- 关于Struts标记库的使用问题,大家请进---〉
- 我擦,领导不懂技术,出了个大难题,小菜鸟哭了,高分求教各路好汉相救
- 编译bean时发生的错误!急求高手解决!
- 谁能详细谈谈如何用J2EE开发分布式应用
- 404错误
- 急在线等...无法使用Database Explorer创建映射文件与持久类
- 高分求助bean:writ问题,高手请进阿!!!!在线等!!!
貌似 是jsp页面标签的问题
把页面上的你修改的内容都删除了 看看...
不是说没有这个数据库得嘛~~
你看看你的边接配置嘛……
hibernate.cfg.xml配置写法如下:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name="connection.username">root</property>
<property name="connection.url">jdbc:mysql://localhost:3306/bookstore</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.password">已经改成我数据库密码</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
//driver也已经添加,分别加再web项目和tomcat
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="myeclipse.connection.profile">mysql</property>
<mapping resource="bookstore/database/Bookinfo.hbm.xml" />
<mapping resource="bookstore/database/Rebate.hbm.xml" />
<mapping resource="bookstore/database/Re.hbm.xml" />
<mapping resource="bookstore/database/Userinfo.hbm.xml" />
<mapping resource="bookstore/database/Orders.hbm.xml" />
</session-factory></hibernate-configuration>连接数据库测试显示错误:
error while performing database login with the mysql driver:
illegal connection port value '3306'
<%
Userinfo user = (Userinfo) session.getAttribute("user");
org.hibernate.Session dbSession = bookstore.database.HibernateUtil.currentSession();
bookstore.database.HibernateUtil.beginTransaction();
org.hibernate.Query query = dbSession.createQuery("from Bookinfo as b where b.remaining>0 order by b.id desc"); query.setMaxResults(6);
java.util.List result = query.list();
System.out.print(result.size());
bookstore.database.HibernateUtil.commitTransaction(); request.setAttribute("books", result);
request.setAttribute("newest", result.get(0)); bookstore.database.HibernateUtil.beginTransaction();
query = dbSession.createQuery("from Orders as o where o.userinfo=:userinfo order by o.id desc");
query.setParameter("userinfo", user);
query.setMaxResults(4);
result = query.list();
bookstore.database.HibernateUtil.commitTransaction();
request.setAttribute("orders", result);
%>
以下是我数据库表单:
# SQL Manager 2005 for MySQL 3.7.5.1
# ---------------------------------------
# Host : localhost
# Port : 3306
# Database : bookstore
SET FOREIGN_KEY_CHECKS=0;DROP DATABASE IF EXISTS `bookstore`;CREATE DATABASE `bookstore`
CHARACTER SET 'latin1'
COLLATE 'latin1_swedish_ci';USE `bookstore`;#
# Structure for the `bookinfo` table :
#CREATE TABLE `bookinfo` (
`id` int(10) unsigned NOT NULL auto_increment,
`bookName` varchar(45) NOT NULL,
`isbn` varchar(45) NOT NULL,
`writer` varchar(45) NOT NULL,
`publisher` varchar(45) NOT NULL,
`intro` text NOT NULL,
`remaining` smallint(5) unsigned NOT NULL,
`picture` varchar(45) NOT NULL,
`date` datetime NOT NULL,
`price` decimal(5,0) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;#
# Structure for the `order` table :
#CREATE TABLE `order` (
`id` int(10) unsigned NOT NULL auto_increment,
`bookid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
`number` tinyint(3) unsigned NOT NULL,
`address` varchar(45) NOT NULL,
`postcode` varchar(45) NOT NULL,
`orderdate` datetime NOT NULL,
`status` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;#
# Structure for the `rebate` table :
#CREATE TABLE `rebate` (
`id` int(10) unsigned NOT NULL auto_increment,
`level` decimal(10,0) NOT NULL,
`rebateRate` decimal(2,0) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;#
# Structure for the `re` table :
#CREATE TABLE `re` (
`id` int(10) unsigned NOT NULL auto_increment,
`bookid` int(10) unsigned NOT NULL,
`userid` int(10) unsigned NOT NULL,
`grade` tinyint(3) unsigned NOT NULL,
`re` text NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;#
# Structure for the `userinfo` table :
#CREATE TABLE `userinfo` (
`id` int(10) unsigned NOT NULL auto_increment,
`username` varchar(45) default NULL,
`pwd` varchar(45) default NULL,
`email` varchar(45) default NULL,
`address` varchar(45) default NULL,
`postcode` varchar(45) default NULL,
`level` decimal(10,0) default NULL,
`power` tinyint(3) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;#
# Data for the `bookinfo` table (LIMIT 0,500)
#INSERT INTO `bookinfo` (`id`, `bookName`, `isbn`, `writer`, `publisher`, `intro`, `remaining`, `picture`, `date`, `price`) VALUES
(1,'dd','dd','dd','dd','dd',5,'1145979122906.gif','2007-06-01',10),
(2,'struts','fff','dd','dd','struts',10,'1145979122906.gif','2007-06-01',20),
(3,'spring','dd','dd','dd','spring',20,'1145979122906.gif','2007-06-01',31);COMMIT;#
# Data for the `order` table (LIMIT 0,500)
#INSERT INTO `order` (`id`, `bookid`, `userid`, `number`, `address`, `postcode`, `orderdate`, `status`) VALUES
(1,1,1,1,'fdf','312473','2006-07-19',0);COMMIT;#
# Data for the `userinfo` table (LIMIT 0,500)
#INSERT INTO `userinfo` (`id`, `username`, `pwd`, `email`, `address`, `postcode`, `level`, `power`) VALUES
(1,'sa','sa','[email protected]','dfdf','312473',0,0);COMMIT;
建议你把sql代码写到查询分析器里看看能不能返回正确的结果
显示有几个表没有EXIST,而且也不是全部的表都不能EXIST。
请问这是因为复制粘贴的原因么?如果是,为什么粘帖到我另外一个电脑就可以呢?
如果不是那是我没有设置好本机的MYSQL 么?如果是,为什么不是所有表都不能EXIST 呢?
我试过直接COPY或者转为.SQL文件导入,或者直接在DOS 命令提示符下导入,或者是使用数据库管理工具
可是很奇怪的是,一样的数据库,能在别的电脑上成功,
但是在我的这里就不行。
导入后选中数据库之后
查询select × from xxxx;表单显示Not exist而,为此我建了一个TEST,同样的操作,却能够显示所有建立的表单