主题:急急急,MYSQL+JSP问题,高手进
大家好,我的jsp页面连接不到数据库,怎么解决,下面是我配置的全过程
red hat linux9系统
j2sdk-1_4_2_08-linux-i586.rpm
jakarta-tomcat-4.0.6.tar.gz
MySQL-server-4.1.14-0.i386.rpm
MySQL-client-4.1.14-0.i386.rpm
安装基于linux的JSP+TOMCAT+MYSQL以上是我所用的软件,下面是配置过程
jdk+tomcat配置
#tar –xzvf jakarta-tomcat-5.0.28.tar.gz
#rpm –ivh j2sdk-1.4.2-08.i386.rpm 默认安装路径是/usr/java/jdk1.4.2-08
设定环境变量如下
在/etc/profile中,加入
java environment variable settings
JAVA_HOME=/usr/java/j2sdk1.4.2_08
export JAVA_HOME
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export CLASSPATH
CATALINA_BASE=/home/jakarta-tomcat-4.0.6
export CATALINA_BASE
CATALINA_HOME=/home/jakarta-tomcat-4.0.6
export CATALINA_HOME
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
在把页面文件aa上传到/home/jakarta-tomcat-4.0.6/webapps/目录下重新启动计算机在IE里输入http://localhost:8080/aa可以看到静态jsp页面,数据库连接不上,因为没装数据库,正常,到此,证明tomcat没问题
安装数据库
#groupadd mysql 建立组
#useradd -g mysql mysql 建立用户
#rpm -ivh MySQL-server-4.1.14-0.i386.rpm安装MYSQL服务端
#rpm -ivh MySQL-client-4.1.14-0.i386.rpm安装客户端
在此数据库安装完毕
#/usr/bin/mysqladmin -u root password 123456将ROOT用户密码设置为123456
#mysql -u root -p
#Enter password:输入密码123456
mysql>到此证明数据成功安装
mysql>create database aa创建aa数据库(aa是页面aa的数据库)
Query OK, 1 row affected (0.06 sec)完成
还原数据库
把win2000上的aa.sql上传到数据库目录/var/lib/mysql
#mysql -u root -p aa < aa.sql数据库成功还原
在设置页面连接数据库文件
#cd /home/jakarta-tomcat-4.0.6/webapps/aa/WEB-INF/classes/com/
#vi LocalStrings.properties
db.url=jdbc:mysql://localhost:3306/aa?user=root&password=123456&characterEncoding=UTF-8
保存退出,重起数据库和tomcat连接不到数据库,错误如下
Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at org.apache.jsp.index$jsp._jspService(index$jsp.java:163)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)
red hat linux9系统
j2sdk-1_4_2_08-linux-i586.rpm
jakarta-tomcat-4.0.6.tar.gz
MySQL-server-4.1.14-0.i386.rpm
MySQL-client-4.1.14-0.i386.rpm
安装基于linux的JSP+TOMCAT+MYSQL以上是我所用的软件,下面是配置过程
jdk+tomcat配置
#tar –xzvf jakarta-tomcat-5.0.28.tar.gz
#rpm –ivh j2sdk-1.4.2-08.i386.rpm 默认安装路径是/usr/java/jdk1.4.2-08
设定环境变量如下
在/etc/profile中,加入
java environment variable settings
JAVA_HOME=/usr/java/j2sdk1.4.2_08
export JAVA_HOME
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export CLASSPATH
CATALINA_BASE=/home/jakarta-tomcat-4.0.6
export CATALINA_BASE
CATALINA_HOME=/home/jakarta-tomcat-4.0.6
export CATALINA_HOME
PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
在把页面文件aa上传到/home/jakarta-tomcat-4.0.6/webapps/目录下重新启动计算机在IE里输入http://localhost:8080/aa可以看到静态jsp页面,数据库连接不上,因为没装数据库,正常,到此,证明tomcat没问题
安装数据库
#groupadd mysql 建立组
#useradd -g mysql mysql 建立用户
#rpm -ivh MySQL-server-4.1.14-0.i386.rpm安装MYSQL服务端
#rpm -ivh MySQL-client-4.1.14-0.i386.rpm安装客户端
在此数据库安装完毕
#/usr/bin/mysqladmin -u root password 123456将ROOT用户密码设置为123456
#mysql -u root -p
#Enter password:输入密码123456
mysql>到此证明数据成功安装
mysql>create database aa创建aa数据库(aa是页面aa的数据库)
Query OK, 1 row affected (0.06 sec)完成
还原数据库
把win2000上的aa.sql上传到数据库目录/var/lib/mysql
#mysql -u root -p aa < aa.sql数据库成功还原
在设置页面连接数据库文件
#cd /home/jakarta-tomcat-4.0.6/webapps/aa/WEB-INF/classes/com/
#vi LocalStrings.properties
db.url=jdbc:mysql://localhost:3306/aa?user=root&password=123456&characterEncoding=UTF-8
保存退出,重起数据库和tomcat连接不到数据库,错误如下
Apache Tomcat/4.0.6 - HTTP Status 500 - Internal Server Error
--------------------------------------------------------------------------------
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
at org.apache.jsp.index$jsp._jspService(index$jsp.java:163)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)