用jsp写的表单用户登录页面,访问mysql数据库时候 出错 ,如下图

在处理登录的时候为什么有时候出现500错误,有时候又出现找不到数据库连接,我用得mysql数据库,驱动程序也添加了的,求大神指教一下啊!
登录页面![登录处理错误页面![注册页面![注册处理错误页面](https://img-ask.csdn.net/upload/201505/20/1432088914_125244.jpg)](https://img-ask.csdn.net/upload/201505/20/1432088899_672024.jpg)](https://img-ask.csdn.net/upload/201505/20/1432088869_715910.jpg)

weixin_44230133
weixin_44230133 最后是怎么解决的
3 个月之前 回复

11个回答

可能数据库没连接上(因为不同数据库版本的驱动不同) 来检查你的数据库是否链接上 在你得到的Connection conn=DriverManager.getConnection(参数); 后面加一段代码 if(conn==null) System.out.println("数据库没连接上") else System.out.println("数据库已连接上") ; 运行tomcat 如果出错,看错误信息 看出现的信息 如果是数据库没连接上 那么,就换一个jdbc的jar包,重新试一试

出现500错误的问题有很多种可能~ 最好是贴代码。

错误代码贴出来……什么都没有
那给你的回答就是你程序写的有问题

1、.htaccess代码的问题。
2、文件权限问题。
第一个问题,可以修改.htaccess文件的文件名试试能否访问,如果问题解决在逐行查看.htaccess文件是否有语法错误。
第二个问题,查看文件权限是否为755若不是手动修改权限。

根据你们的描述最大的可能就是参数出问题了,核实一下通过界面传递过去的参数是否有非法参数,是否正常接收及传递。

只要你的服务器程序丢出了异常,甭管是除数为0还是数据库连不上,都会是500错误。

端口号对好了吗 还有就是用户民密码啊

端口号对好了吗 还有就是用户民密码啊

端口号对好了吗 还有就是用户民密码啊

我用的是MyEclipse 10.0,mysql数据库(Navicat_for_MySQL_11.0.10_XiaZaiBa.exe),jdk1.8.0_11,Tomcat 6.0,mysql-connector-java-5.1.26-bin.jar,
这几天一直处理不了登录信息,还请大家多多帮忙啊
数据库连接代码如下:
package com.cqut.dao.util;

import java.sql.Connection;
import java.sql.DriverManager;

public class DataBaseCon {
private static String driverName = "com.mysql.jdbc.Driver";
private static String userName = "root";
private static String password = "root";
private static String url = "jdbc:mysql://localhost:3306/booksmanage";
public static Connection getCon() throws Exception {
Class.forName(driverName);
Connection con = DriverManager.getConnection(url,userName,password);

return con;
}

}

登录处理代码如下:
<%@ page language="java"  import="java.util.*" pageEncoding="utf-8"%>

<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@page import="com.cqut.dao.util.DataBaseCon" %>
<%@page import="java.sql.*"%>
<%@page import="javax.swing.JOptionPane"%>

/jsp:UseBean
/jsp:useBean

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


https://img-ask.csdn.net/upload/201505/20/1432114316_284852.jpg)
我的数据库如下:
数据库
数据库驱动程序也导入到项目里面的,如下:
图片说明
共11条数据 1 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
jsp如访问mysql数据库
我已经下载好了mm.mysql.jdbc.tar,并解压放在c:\mysql-jdbc,在classpath里也加上了路径,但程序还是出错:说org.git.mm.mysql.Driver没找到,我用的是tomcat4.01,我该怎么办?
请问,用JSP做用户登录页面怎么写啊!
谢谢!
用jsp写一个简单的登录页面
求写一个登录页面,有form表单,然后能提交到数据库。框架是spring,数据库是sql,用java,jsp写。。我是新手,所以恳求大神帮帮我。非常感谢谢。。
如何强制用户访问登录页面?
我试过以下方法:rn1.在global.asa中的session_on_start中加代码,但只能控制第一次。rn2.把控制代码写在inc中,但要在每一个asp中include这个inc.rn请问有没有更方便有效的方法?谢谢!
如何在JSP中访问MySQL数据库上篇
如何在JSP中访问MySQL数据库上篇 如何在JSP中访问MySQL数据库上篇
jsp连接mysql数据库出错。。
org.apache.jasper.JasperException: Exception in JSP: /javascript/zhuce_insert.jsp:10rnrn7: String driverName = "com.mysql.jdbc.Driver";rn8: String url = "jdbc:mysql://localhost:3306/stu_inform";rn9: Class.forName("com.mysql.jdbc.Driver");rn10: Connection conn = DriverManager.getConnection(url,"root","");rn11: Statement statement = conn.createStatement();rn12: String sql = "insert into stu_record values(" + request.getParameter("stuname") + "," + Integer.parseInt(request.getParameter("stunum")) + "," + request.getParameter("stuem") + ")";rn13: statement.executeUpdate("sql");rnrnrnStacktrace:rn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrn我的mysql已经启动,tomcat也已经启动,我不知道数据库的用户名和密码,不知道再哪看。反正进去就能用的,本来用户名和密码那我都填空的,但是不行,后来就加个root用户名上去了。rn我将 mysql-connector-java-3.1.0-alpha-bin.jarrn复制到了我的/tomcat/webapps/ROOT/WEB-INF/lib下了,不知道还需要什么配置没??请大家帮帮我,谢谢!!
jsp调用mysql数据库出错!
tryrn rn Class.forName("org.gjt.mm.mysql.Driver").newInstance();rn System.out.println("JDBC driver loaded");rn con=DriverManager.getConnection("jdbc:mysql://localhost/wrox?user=root&password=root");rn System.out.println("Database connection established");rn Statement stmt=con.createStatement();rn************************************rn String upd= "create table author(rn author_id integer not null primary key,rn author_name char(50));";rn*****************************//出错!提示如下:rnCreateTable.java:14: 未封闭的文字字符串rn String upd= "create table author(rn ^rnCreateTable.java:16: 未封闭的文字字符串rn author_name char(50));";rn ^rn*****************************************rn stmt.executeUpdate(upd);rn System.out.println("Table-author created");rn
jsp访问mysql数据库的问题
我用netstat查看系统连接时发现mysql建立的连接非常多,贴一段出来rntcp 0 0 192.168.0.1:40151 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40148 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40149 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40138 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40139 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40136 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40137 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40142 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40143 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40140 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40141 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40130 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40131 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40128 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40129 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40134 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40135 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40132 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40133 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40122 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40123 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40120 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40121 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40126 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40127 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40124 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40125 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40114 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40115 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40118 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40119 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40116 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40117 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40208 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40203 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40202 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40201 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40200 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40207 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40206 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40205 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40204 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40195 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40194 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40193 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40192 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40199 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40198 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40197 192.168.0.1:mysql TIME_WAIT rntcp 0 0 192.168.0.1:40196 192.168.0.1:mysql TIME_WAIT rnrn什么原因??我只是用jsp访问mysql用到mysql
jsp 访问mysql数据库的字符串
1、在mysql中数据库的字符串数值为:rn我司经三个国际局转接到中国联通的部分电话仍然不能接通,拔打后听录音:拔打外地手机,请加拔"0".rnrn2、我想在jsp页面中访问显示匀为正常:rn我司经三个国际局转接到中国联通的部分电话仍然不能接通....rnrn3、但是我在生成excel文件的时候把字符串写入excel文件时它的数值也为:rn我司经三个国际局转接到中国联通的部分电话仍然不能接通,拔打后听录音:拔打外地手机,请加拔"0".rnrnrn请问:我怎样才能把中文形式的字符串写入excel文件???谢谢!!!rn
jsp 访问MYSQL数据库
小弟我尝试访问MYSQL数据库,怎么总不成功呀:<%@ page contentType="text/html;charset=gb2312"%> rn<%@ page import="java.sql.*"%> rn rn <%Class.forName("org.gjt.mm.mysql.Driver").newInstance(); rn String url ="jdbc:mysql://localhot/CLDB"; rn //testDB为你的数据库名 rn Connection conn= DriverManager.getConnection(url,"root",""); rn Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); rn String sql="select * from Songs"; rn ResultSet rs=stmt.executeQuery(sql); rn while(rs.next()) %> rn 您的第一个字段内容为:<%=rs.getString(1)%> rn 您的第二个字段内容为:<%=rs.getString(2)%> rn <%%> rn <%out.print("数据库操作成功,恭喜你");%> rn <%rs.close(); rn stmt.close(); rn conn.close(); rn %> rn rn rn
JSP访问mysql数据库
在jsp中当创建登录表单时,可以与数据库中的一些已经存在的信息进行对比,进而判断是否存在已有用户,本篇只实现简要介绍jsp访问数据库,只实现查询功能,其余功能类似。使用IDEA编译器,首先配置文件:首先在web文件夹下创建lib目录(右键项目,New -&amp;gt; Directory -&amp;gt;创建文件夹即可),把mysql驱动器复制到lib目录下,然后File -&amp;gt; Project Stru...
Jsp访问MySql数据库
2个JSP页面 rn从JSP01上抓取用户输入的中文信息插入到MyS 表中rn在JSP02上显示插入数据库的信息
jsp访问操作mysql数据库
jsp访问操作mysql数据库
如何在Oracle数据库写存储过程访问MySql数据库
如何在Oracle数据库写存储过程访问MySql数据库?rnrn谢谢大虾
使用jsp实现登录页面,增删改查页面,mysql数据库。
jsp+jdbc+servlet+mysql数据库增删改查sql命令 分页查询等功能
用jsp中的getConnection访问mysql数据库的问题
private static String stringConn = "jdbc:mysql://localhost:3306/example";rn private static String stringUser = "root";rn private static String stringPsw = "";rn ..rn sqlConn = java.sql.DriverManager.getConnection(stringConn, stringUser,rn stringPsw);rn rn 在mysql里面我设了localhost的权限,用mysql -u root -p可以进入mysqlrn rn 但是用jsp来读的时候却出现Access denied for user: 'example@localhost.local'的错误rn rn 然后我在mysql里面添加啦localhost.local的权限,这时候jsp可以读数据啦,一切正常rn rn 这是为什么呢?我在stringConn那里明明写的是localhost为什么在jsp却读成localhost.local?rn rn 而localhost.local到底是什么来的?请各位大虾指点指点rn
登录页面出错
(1)这是登录页面denglu.asp主要相关代码:rn<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>rnrnrnrnrnrn rn 登录页面rn rnrnrnrn rn rn rn 请您登录rn rn rn 用户名rn rn rn rn 密码rn rn rn(2)这是登录页面处理代码dengluasp.asprnrn<%rndim rse,sqluserrnset rse =server.CreateObject("adodb.recordset")rnsqluser="select * from userinfo"rnrse.open sqluser,conn,1,3rnif rse("username")<>request("name") thenrn response.Write("用户名错误!")rn elsern if rse("password")<>request("pass") thenrn response.Write("密码错误!")rn elsern response.Write("登录成功!")rn end ifrnend ifrnset rse=nothingrnconn.closernset conn=nothingrn%>rnrn(3)当登录的时候总是显示“用户名错误!”rn这是我的分析:应该是这句错误rse("username")<>request("name") rn但是数据库中userinfo表的username字段与姓名输入文本框NAME属性名称name不一致,rn但是,仔细检查后是一致的。rn请指教,谢谢!
用户登录页面
对于java初级学员,采用按部就班的学习方式,入门java企业级开发模式,至少需要2~3个月的时间。很多学员很快就没有了 信心!rn本套课程,帮你精选了java企业级开发的核心部分,让你入门。rn有兴趣的学员,入门后再进行细致深入的学习,会起到事半功倍的作用!
jsp如何用mysql数据库。
同上。
如下图
[img=http://hi.csdn.net/space-2321951-do-album-picid-601040.html][/img]rn我想问winform如何将这个表里的数据办绑定到treeview treeview上是有chenckbox的
jsp登录页面
jsp登录页面 1.技术应用 1.GET,POST的区别 GET - 从指定的资源请求数据。 数据在 URL 中对所有人都是可见的。不安全 POST - 向指定的资源提交要被处理的数据 数据不会显示在 URL 中.安全 2.请求转发与请求重定向 (1) RequestDispatcher.forward方法只能将请求转发给同一个WEB...
C# 访问mysql数据库 conn.Open();出错
代码如下nn```n MySQLConnection conn = null;n conn = new MySQLConnection(new MySQLConnectionString("localhost", "wsnvlab", "root", "123456").AsString);n n tryn n conn.Open();n n catch(Exception e)n n n return conn;n```n执行到 conn.Open();时出错,错误提示n无法加载 DLL“libmySQL.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。n该怎么解决n
jsp登录页面代码jsp登录页面代码
自己写的登录页面自己写的登录页面自己写的登录页面自己写的登录页面
JSP访问时出错
安装了jdk1.8版本或tomcat8.0版本后运行之前jsp项目报错:org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: [45] in the generated java file: [F:\apache-tomcat-8.0.14\work\Catalina\localhost\MoniWeb\org\apache\jsp\jsp\main_jsp.java] The method getDispatcherType() is undefined for the type HttpServletRequest
jsp访问出错!
本人准备做小项目自己玩玩。却出现这样的问题.rnrn环境配置:eclipse3.2.1+myeclipse5.5+tomcat5.5,tomcat启动没有问题。访问login.jsp就出如下问题!rnrnrn看错误像是找不到FacesServlet,但是j2ee自带的jar中已经包含,jsf-api.jar,jsf-impl.jar两个包,rncommons-digester.jar这个是自己加进去的!rnrnrn错误如下!rntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnjavax.servlet.ServletException: Wrapper cannot find servlet class javax.faces.webapp.FacesServlet or a class it depends onrn org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)rn org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)rn org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)rn org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)rn org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)rn org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)rn org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)rn java.lang.Thread.run(Thread.java:595)rnrnrnroot cause rnrnjava.lang.ClassNotFoundException: javax.faces.webapp.FacesServletrn org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1355)rn org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1201)rn org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)rn org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)rn org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)rn org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)rn org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)rn org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)rn org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)rn java.lang.Thread.run(Thread.java:595)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.rnrnweb.xml配置rn[code=XML]rnrnrnrn rn facesContextrn javax.faces.webapp.FacesServletrn rn rn rn facesContextrn *.jsprn rnrn rn login.jsprn rn rn rnrnrnrn[/code]rn
KindEditor调用出错,异常信息如下图
[img=https://img-bbs.csdn.net/upload/201503/17/1426559438_365882.png][/img]rn这个是写的代码,和官网是一样的,怎么会有 Uncaught TypeError: undefined is not a function 这个异常信息呢???rn rn rn rn rn rn
用JDBC访问MySql数据库
创建MySql数据库 创建数据库 create database   databasename; 调用数据库 use databasename; 创建数据表 create table  tablename(字段1  [数据类型] 【主键】,字段2,字段3 ); 显示数据库 show databases;  (注意:databases后的s) 显示数据表 show tab
JSP 访问RequestBean 出错
package bean;rnimport java.io.Serializable;rnrnpublic class CounterBean implements Serializablern int count=0;rn public CounterBean()rn rn public int getCount()rn count++;rn return count;rn rn public void setCount(int c)rn count=c;rn rn rn--------------------------------------------rnCountBean代码 放在E:\tomcat\webapps\test\WEB-INF\classes\bean下面rnrnrn rn rn CounterBean scope="request" Examplern <%counterBean.setCount(100);%>rn rn <% rn rn %>rn rn <% --response.sendRedirect("RequsetBean2.jsp");--%>rn rn rn--------------------------------RequestBean.jsprnrnrn rn rn CounterBean scope="request" Examplern count:<%=counterBean.getCount()%>rn rn rn ------------------------RequestBean2.jsprn访问RequestBean.jsp报错rntype Exception reportrnrnmessagernrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexceptionrnrnorg.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 11 in the jsp file: /RequestBean.jsprnSyntax error on token(s), misplaced construct(s)
用Go-SQL-Driver访问mysql数据库
go语言提供了数据库访问的统一接口,但是自己自己的具体数据库访问驱动实现。开源比较常用的有go-sql-driver/mysql(原来的go-mysql-driver)和mymysql我个人比较倾向于go-sql-driver,实现规范,通用性强Go-SQL-Driver是它的新名字,已经迁移到了gitbub,地址:https://github.com/Go-SQL-Driver/MySQL安...
jsp访问mysql出错
我的代码是rn<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*,java.io.*"%>rnrnrn rn ID 书名 出版社 价格rn<%! String trans(String chi)rnrn String result = null;rn byte temp [];rn tryrn rn temp=chi.getBytes("iso-8859-1");rn result = new String(temp);rn rn catch(UnsupportedEncodingException e)rn rn System.out.println (e.toString());rn rn return result;rnrn%>rn<%rnrn Class.forName("com.jdbc.mysql.Driver").newInstance();rn Connection con=java.sql.DriverManager.getConnection("jdbc:mysql://localhost/web","root","51401991");rn Statement stmt=con.createStatement();rn ResultSet rst=stmt.executeQuery("select * from user");rn while(rst.next())rn rn out.println(" ");rn out.println(" "+rst.getString("userName")+"");rn out.println(" "+trans(rst.getString("regTime"))+"");rn out.println(" "+trans(rst.getString("email"))+"");rn out.println("");rn rn //关闭连接、释放资源rn rst.close();rn stmt.close();rn con.close();rn %>rnrnrnrn总是报错:org.apache.jasper.JasperException: An exception occurred processing JSP page /mysql.jsp at line “Class.forName("com.jdbc.mysql.Driver").newInstance();”rn我用java程序可以正常访问,但用jsp就出错
用javaSwing和mysql数据库做的一个登录页面
一:首先在eclipse中新建一个java工程 二:然后新建一个包,并且在包中新建两个类:一个事登录用的界面(Login)类,一个事连接数据库的(jdbcs)类我建立的是p4这个包 三:导入包mysql-connector-java-8.0.16.jar并且要添加到构建路径不添加到构建路径项目工程不会读出来的 (原先的驱动com.mysql.jdbc.Driver已经升级到了com.mysq...
请教:jsp备份恢复mysql数据库出错
jsp备份恢复mysql数据库出错:rnrn采用网上看到的代码,稍加修改变成我的struts里的action:rnrntry rn Runtime rt = Runtime.getRuntime();rn String mysql="mysqldump -uroot -p111 cntrans";rn String backupPath="D:\\cntrans.sql";rn rn Runtime runtime = Runtime.getRuntime();rn FileWriter fw = new FileWriter(backupPath); rn Process child = runtime.exec("cmd /c "+mysql);rn InputStreamReader irs = new InputStreamReader(child.getInputStream()); rn BufferedReader br = new BufferedReader(irs);rn String line;rn while( (line=br.readLine()) != null ) rn fw.write(line + "\n");rn rn fw.close();rn irs.close();rn br.close(); rn errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("admin.processed"));rn saveMessages(request,errors);rn return mapping.findForward("success");rn rn catch(Exception e)rn e.printStackTrace();rnrn errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage("admin.failed"));rn saveMessages(request,errors);rn return new ActionForward(mapping.getInput());rn rnrn但是用此方法,得到的是一个空的cntrans.sql文件。rn
jsp之用户访问实例
jsp之用户访问 当用户登陆jsp页面时 页面访问次数会递加 不会因 点刷新递加 访问次数 是动态的 可以自己找图片修改
jsp登录页面输入用户名、密码后出错
jsp登录页面输入用户名、密码后出错。看不懂,请高手指点。数据库用的mysql,不知道是数据库的问题,还是别的什么问题。rnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnjavax.servlet.ServletException: General error, message from server: "Can't find file: '.\zcglxt\??????.frm' (errno: 22)"rn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)rn org.apache.jsp.jsp.login_jsp._jspService(login_jsp.java:507)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnroot cause rnrnjava.sql.SQLException: General error, message from server: "Can't find file: '.\zcglxt\??????.frm' (errno: 22)"rn com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)rn com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)rn com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)rn com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1164)rn com.mysql.jdbc.Connection.execSQL(Connection.java:2087)rn com.mysql.jdbc.Connection.execSQL(Connection.java:2037)rn com.mysql.jdbc.Statement.executeQuery(Statement.java:1156)rn org.apache.jsp.jsp.login_jsp._jspService(login_jsp.java:374)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.rnrn
jsp往mysql数据库插入数据出错
我从网上下了段jsp添加数据的代码,自己运行时却一直出错,求各位高人指点一下rn前面是一段html表单代码,就不贴了,这是jsp的代码rn rn<%! rnString id = ""; rnString title = ""; rnString source = ""; rnString content = ""; rnString sender = ""; rnString sId = ""; rnString cheng = ""; rnint i = 0; rnrn %> rn rn<% rn//接收来自html页面提交的参数 rnthis.id = request.getParameter("id"); rnthis.title = request.getParameter("title"); rnthis.source = request.getParameter("source"); rnthis.content= request.getParameter("content"); rnthis.sender = request.getParameter("sender"); rn//为了防止中文乱码 rnthis.id = new String(this.id.getBytes("ISO-8859-1"),"GB2312"); rnthis.title= new String(this.title.getBytes("ISO-8859-1"),"GB2312"); rnthis.source= new String(this.source.getBytes("ISO-8859-1"),"GB2312"); rnthis.content = new String(this.content.getBytes("ISO-8859-1"),"GB2312"); rnthis.sender = new String(this.sender.getBytes("ISO-8859-1"),"GB2312"); rn %> rn rn rn rnrn <% rnthis.i = myBean.getSum() + 1; rnthis.cheng = myBean.setDate(this.id,this.title,this.source,this.content,this.sender); rnout.println(" "+this.cheng + ""); rnout.println("现在数据库中的总记录数为:"+i); rnmyBean.closeDate();//关闭对数据库的操作 rn %>rn rn rn 刚才插入的数据如下: rn rn <%= this.id %> rn <%= this.title %> rn <%= this.source %> rn <%= this.content %> rn <%= this.sender%> rn rn rn rn rn rn然后是一个javabean操作数据库的rnpackage MyBean; rnimport java.io.*; rnimport java.sql.*; rnpublic class liao rn rnString driver,url,user,pwd,SQL; rnConnection con;//连接对象 rnStatement stat;//SQL语句对象 rnResultSet rs;//结果集对象 rnString id,title,source,content,sender;//取数据库中的数据用到 rnString newid,newtitle,newsource,newcontent,newsender;//插入数据到数据库中用到 rnint number;//记录当前结果集数据总行数 rn rnpublic liao() throws Exception rn rnthis.con = null; rnthis.stat = null; rnthis.rs = null; rnthis.number = 0; rnrn this.url ="jdbc:mysql://localhost/db?user=root&password=123&useUnicode=true&characterEncoding=8859_1"; rnthis.SQL = "select * from news"; rnthis.newid = ""; rnthis.newtitle = ""; rnthis.newsource = ""; rnthis.newcontent = ""; rnthis.newsender = ""; rnrnrnthis.id = ""; rnthis.title = ""; rnthis.source = ""; rnthis.content = ""; rnthis.sender = ""; rnrnClass.forName("com.mysql.jdbc.Driver").newInstance();//加载数据库驱动并注册 rnthis.con = DriverManager.getConnection(url);//连接数据库 rnthis.stat = con.createStatement();//创建语句对象 rnthis.rs = stat.executeQuery(this.SQL);//返回结果集合对象 rnrn rn rn rn//把数据插入数据库 rnpublic String setDate(String id,String title,String source,String content,String sender ) throws Exception rn rnthis.newid = id; rnthis.newtitle = title; rnthis.newsource =source ; rnthis.newcontent =content; rn this.sender = sender; rnString SQL1 = "insert into news values('"; rnString SQL2 = "','"; rnString SQL3 = "')"; rnString SQL = SQL1+ this.newid + SQL2 + this.newtitle + SQL2 + this.newsource + SQL2 + this.newcontent + SQL2 + this.newsender + SQL3; rnthis.stat.executeUpdate(SQL); rnreturn "添加新闻成功!"; rn rn rn//统计结果集共有几条记录 rnpublic int getSum() throws SQLException rn rnwhile(this.rs.next()) rn rnthis.number = this.number + 1; rn rnreturn this.number; rn rnrn//从数据库中取回数据 rnpublic String getid() throws UnsupportedEncodingException,SQLException rn rnthis.id = this.rs.getString("id"); rnreturn new String(id.getBytes("ISO-8859-1"),"GB2312"); rn rnpublic String gettitle() throws UnsupportedEncodingException,SQLException rn rnthis.title = this.rs.getString("title"); rnreturn new String(title.getBytes("ISO-8859-1"),"GB2312"); rn rnpublic String getsource() throws UnsupportedEncodingException,SQLException rn rnthis.source = this.rs.getString("source"); rnreturn new String(source.getBytes("ISO-8859-1"),"GB2312"); rn rnpublic String getcontent() throws UnsupportedEncodingException,SQLException rn rnthis.content = this.rs.getString("content"); rnreturn new String(content.getBytes("ISO-8859-1"),"GB2312"); rn rnrnpublic String getsender() throws UnsupportedEncodingException,SQLException rn rnthis.sender = this.rs.getString("sender"); rnreturn new String(sender.getBytes("ISO-8859-1"),"GB2312"); rnrnrn//关闭对数据库的操作 rnpublic void closeDate() throws SQLException rn rnthis.stat.close(); rnthis.con.close(); rn rn rn rn问题是当我提交表单数据后出错提示rnorg.apache.jasper.JasperException: 无法编译JSPrnrnAn error occurred at line: 33 in the jsp file: /incept.jsprnGenerated servlet error:rnThe method setDate(String, String, String, String, String, String) in the type liao is not applicable for the arguments (String, String, String, String, String)rnrnrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrn起 因 rnrnorg.apache.jasper.JasperException: 无法编译JSPrnrnAn error occurred at line: 33 in the jsp file: /incept.jsprnGenerated servlet error:rnThe method setDate(String, String, String, String, String, String) in the type liao is not applicable for the arguments (String, String, String, String, String)rnrnrn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)rn org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rn麻烦各位了,如果满意我还会另加分rnrn
在Jsp中访问mySQL数据库的问题
在Jsp页面里如直接访问数据库则可以得到数据,但如果将数据库的访问封装成一个DB类后,每次调用这个DB类时,执行到stat.executeQuery(sql)时就会报错,不知何故,有没有人遇到这个问题啊?哦,说明下,以前的这个程序用的是SQL,可以正常使用。
用JSP连接mysql数据库
1.安装mysql 请参阅资料版区相关文章 http://info.mysql.cn/install/2006/0208/81.html 2.JDBC驱动:mysql-connector-java-3.1.8 这只是一个压缩包,并不需要安装,只要将其解压,我么使用的是文件夹mysql-connector-java-3.1.8里的文件:mysql-connector-java-3.1.8-bin.jar. 3. Mysql界面插件:mysql-front 这是一个安装程序,按照提示安装就可以了.
十万火急,jsp做TreeListView,如下图
[img=http://www.codeproject.com/KB/WPF/wpf_treelistview_control/WpfTreeListView.PNG][/img]rnrn这个TreeListView列表,用jsp怎样实现?rn做过的请讲讲主要思路,没做过的请发表一下建议。rn
mysql 用navicat导出数据 的时候 出现 下图
cna't create/write to file 'e:\database\-install\#sql_ee8_0.MYI'(Errcode:2)这是什么错误啊 请高手 帮忙了 急啊
用SOCKET访问JAVA写的WEBSERVICE出错
返回错误信息如下:rnHTTP/1.1 501 Method POST is not defined in RFC 2068 and is not supported by the Servlet API rnX-Powered-By: Servlet 2.4; Tomcat-5.0.28/JBoss-4.0.0 (build: CVSTag=JBoss_4_0_0 date=200409200418)rnContent-Type: text/html;charset=utf-8rnContent-Length: 1868rnDate: Thu, 17 Jun 2010 07:59:18 GMTrnServer: Apache-Coyote/1.1rnConnection: closern-----------------------------------------------rn具体情况如下:rn我需要用SOCKET去访问服务器端的一个WS(JAVA写的),真实环境中需要过网闸(服务器和客户端不在一个网络)。rn同样的代码,如果我不过网闸(也就是在一个网络内)去访问WS已经可以访问到了,但是只要一在实际环境中,过了网闸之后就会返回上面的错。rn另外我用抓包工具SmartSniff在WS的机器上抓包看了一下,如果不过网闸的话,抓到的数据包就是一个字符串,跟我发送的完全一样,但是如果过了网闸的话,抓到的数据包有一些十六进制的数据,也有我发送的字符串(左边是十六进制,右边是我发的数据,每一行左边的十六进制其实就是右边的字符串)。rn不知道有没有哪位大侠遇到过!!rn另外我发送的字符串如下:rn[code=C#]rn string soap4= @"rnrnrnrntestrnrnrn";rnrnrn string httpHeader4 = @"POST /testWS/services/HelloServices HTTP/1.1rnUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3603)rnContent-Type: text/xml; charset=utf-8rnSOAPAction: """"rnHost: 192.168.0.169:8080rnContent-Length: " + soap4.Length + @"rnExpect: 100-continuernConnection: Keep-Alivernrn";rnrn[/code]rnSOCKET发送的是httpHeader4 + soap4rn
相关热词 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法