python连接mysql执行source命令出错。。

图片说明

如这张图片所示。百思不得其解中。。求大神指教。。

0

1个回答

你的sql文件是否有语法错误,你直接mysql命令行能source执行成功?

0
qq_36750158
全世界我倾听你 我在网上看到的事mysqldb对mysql文件支持不友好,可以用http://www.php.cn/mysql-tutorials-82322.html这个网页上的例子写。我也碰到这问题了
4 个月之前 回复
wing324
wing324 我直接是成功的,这里面没有语法错误。就是我在想是不是python连接mysql不支持source命令呢?。。。
4 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
python对多个数据库执行mysql的source命令
为什么80%的码农都做不了架构师?>>> ...
MySQL通过source命令执行sql文件
见百度:https://jingyan.baidu.com/article/e75057f2e284ceebc91a891b.htmlIT人员经常会和MySQL打交道,备份和恢复应该是最常用的操作了,那么通过直接执行sql文件无疑是最快捷的方式,本文通过转储sql文件,并在新数据库中执行sql文件,来介绍如何在命令行中执行sql文件打开cmd窗口,根据MySQL安装目录,在cmd命令下输入如下命令...
mysql source命令
我的mysql版本是5.0.22rn结果不能使用source命令,使用老是报错,难道版本较低不能使用吗?rnmysql> source “正确文件全路径名”rn执行报错,如果版本是5.0.67的话就OK,rnrn我的问题是:source命令跟mysql版本有关吗?疑惑
Python连接mysql执行操作
import pymysql db = pymysql.connect(host='localhost', port=3306, user='root', passwd='root', db='test', charset='utf8') cursor = db.cursor() # 创建游标对象 def i...
shell脚本中执行source命令
我有个需求,希望有大侠指点rn我不希望在命令窗口输入 source test.shrn我希望能把这个命令写在脚本config.sh中,因为有很多这种操作(source file)。rn当我在窗口执行config.sh时无任何效果。期望source file能有效执行。rn请问如何实现?先谢谢了。rnrn
在mysql 4.1.8里执行左连接出错
在mysql 4.1.8里执行左连接出错.php版本是4.3rn在版本mysql4.0,php 4.0.3执行就没问题.rnrnsql语句:SELECT c_9.red, c_9.id, c_9.price_jzk, c_9.price_jqtrnFROM c_9 LEFT JOIN c_4 ON c_9.khxm = c_4.khxm ORDER BY to_days( c_4.q_date ) DESC rnLIMIT 0 , 30 rn错误提示:rnIllegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin1_bin,IMPLICIT) for operation '='rn
在mysql 4.1.8里执行左连接出错.
在mysql 4.1.8里执行左连接出错.php版本是4.3rn在版本mysql4.0,php 4.0.3执行就没问题.rnrnsql语句:SELECT c_9.red, c_9.id, c_9.price_jzk, c_9.price_jqtrnFROM c_9 LEFT JOIN c_4 ON c_9.khxm = c_4.khxm ORDER BY to_days( c_4.q_date ) DESC rnLIMIT 0 , 30 rn错误提示:rnIllegal mix of collations (latin1_swedish_ci,IMPLICIT) and (latin1_bin,IMPLICIT) for operation '='rnrn
mysql source命令的问题
bbs.sql 文件内容如下:rn[color=#FF9900]create database bbs;rnuse bbs;rncreate table articlern(rn id int not null,rn pid int not null,rn isleaf int not null,rn cont text,rn primary key (id)rn);rnrninsert into article valuesrn (0, -1, 0, '我想报考****学院,这个学校怎么样啊?'),rn (1, 0, 0, '垃圾,很小一个学校'),rn (2, 1, 1, '你才垃圾,你牛逼啊, 人家好坏也是....'),rn (3, 0, 0, '在,,,还是比较不错的'),rn (4, 3, 0, '说的没错'),rn (5, 4, 1, '我支持'),rn (6, 4, 1, '我也支持');[/color]rnrnrn1、首先是 source f:\bbs.sql;rn我就是在F盘根目录放着,可是仍然提示 rnFailed to open file 'F:\bbs.sql;', error: 2rnrn2、于是我把脚本文件放在source命令所在的bin目录下,这会没有提示找不到文件,却有:rnDatabase changedrnQuery OK, 0 rows affected (0.05 sec)rnrnERROR 1366 (HY000): Incorrect string value: '\xE6\x88\x91\xE6\x83\xB3...' for cornlumn 'cont' at row 1rnrn此时查询表中内容为空,但是我将rnnsert into article valuesrn (0, -1, 0, '我想报考****学院,这个学校怎么样啊?'),rn (1, 0, 0, '垃圾,很小一个学校'),rn (2, 1, 1, '你才垃圾,你牛逼啊, 人家好坏也是....'),rn (3, 0, 0, '在,,,还是比较不错的'),rn (4, 3, 0, '说的没错'),rn (5, 4, 1, '我支持'),rn (6, 4, 1, '我也支持');rn复制到MySQL的命令行里运行却是一点问题都没有rnrn另外,还有一个,我用mysql administratator 在 Query Browser里使用中文查询rn例如 select * from student where name='张三'时,'张三'显示的是重叠的样子rn就是汉字重在一起。如果汉英混合也是重叠,纯英语就显示的很正常了rn当然查询结果可以出来的。rnrn请教大侠,这都是怎么回事?rnrnrn
mysql导入sql文件,source命令
1. 首先查看原文件在电脑的位置 2. 在mysql命令行输入: source 文件所在路径
毕业设计之mysql的source命令
windows执行source C:\Users\plp\Desktop\cloud_psychology.sql 报错Unknown command '\U'  Unknown command '\D'   Unknown command '\?' 原来是因为window中的'\'的问题 改为source C:/Users/plp/Desktop/cloud_psychology.sql
mysql执行存储过程出错
存储过程 用于分页为:rn[code=sql]rnDELIMITER $$rnrnDROP PROCEDURE IF EXISTS `p_pageList` $$rnCREATE DEFINER=`root`@`localhost` PROCEDURE `p_pageList`(rn m_pageNo int,rn m_perPageCnt int,rn m_column varchar(1000),rn m_table varchar(1000),rn m_condition varchar(1000),rn m_orderBy varchar(1000),rn out m_totalPageCnt intrn)rnBEGINrnSET @pageCnt=1;rnSET @limitStart=(m_pageNo-1)*m_perPageCnt;rnSET @limitEnd=m_perPageCnt;rnSET @sqlCnt=CONCAT('select count(*) into @pageCnt from ',m_table);rnSET @sql=CONCAT('select ',m_column,' from ',m_table);rnIF m_condition IS NOT NULL AND m_condition <>'' THENrnSET @sql=CONCAT(@sql,' where ',m_condition);rnSET @sqlCnt=CONCAT(@sql,' where ',m_condition);rnEND IF;rnIF m_orderBy IS NOT NULL AND m_orderBy <>'' THENrnSET @sql=CONCAT(@sql,' order by ',m_orderBy);rnEND IF;rnSET @sql=CONCAT(@sql,' limit ',@limitStart,',',@limitEnd);rnSELECT @sql;rnPREPARE s_cnt from @sqlCnt;rnEXECUTE s_cnt;rnDEALLOCATE PREPARE s_cnt;rnSET m_totalPageCnt=@pageCnt;rnPREPARE record from @sql;rnEXECUTE record;rnDEALLOCATE PREPARE record;rnEND $$rnrnDELIMITER ;rn[/code]rn执行过程中同时输出执行的语句。。。rn[code=sql]rnCALL p_pageList(1,10,'*','movie','genres','movieid',@X);rn[/code]rn提示错误rnYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where genres' at line 1rn但是我复制了所输出的sql语句执行,可以输出结果。。所以不知道错在哪里???只要condition那个地方写成'',则可以得到结果 rn请问where语句那里错在哪里?
执行mysql出错
麻烦问下 我在执行rn #bin/mysqld_safe --user=mysql &rn的时候提示 rn[1] 31799 You have new mail in /var/spool/mail/root [root@localhost mysql]# Starting mysqld daemon with databases from /usr/local/mysql/var STOPPING server from pid file /usr/local/mysql/var/localhost.localdomain.pid 101029 01:27:29 mysqld ended rnrn为什么打开了 然后就关闭了?
mysql执行出错!
连续查询时出错,Lost connection to MySQL server during queryrn 出错过程如下,我先检查某表是否有相关记录,没有的话插入一条A,A插入后在另一个表中插入记录B,就在插入B时出了这个错误~rn [code=C/C++]rn if (NULL!=mysql&&mysql->status==MYSQL_STATUS_READY)rn rn //用于查询rn int ret=0;rn //收集查询结果 rn MYSQL_RES *res_ptr=NULL; rn //显示字段名 rn MYSQL_ROW sqlrow=NULL; rn int num_fields=0;rnrn ret=mysql_real_query(mysql,sql.GetBuffer(),sql.GetLength()); rn if(0!=ret) rn rn //查询失败rn ::LeaveCriticalSection(&waitingAccessMySql);rn const char * err=mysql_error(mysql);rn CString errMsg;rn errMsg.Format("%s,%s",err,"查询收藏产品失败");rn ::MessageBox(TuanGouDlgPtr->m_hWnd,errMsg.GetBuffer(),"",0);rn return success;rn rnrn //获取查询结果 rn res_ptr=mysql_store_result(mysql); rn if(NULL!=res_ptr) rn rn //若存在这条记录 就不能再添加rn int rowCount=(unsigned long)mysql_num_rows(res_ptr);rn if (rowCount>0)rn rn success=true;rn rn elsern rn //产品已经收藏rn success=false;rn rn mysql_free_result(res_ptr);rn rn rn 这是查询是否存在rn if (NULL!=mysql&&mysql->status==MYSQL_STATUS_READY)rn rn //用于查询rn int ret=0;rn ret=mysql_real_query(mysql,sql.GetBuffer(),sql.GetLength()); rn if(0!=ret) rn rn const char * err=mysql_error(mysql);rn CString errMsg;rn errMsg.Format("%s,%s",err,"收藏失败");rn ::MessageBox(TuanGouDlgPtr->m_hWnd,errMsg.GetBuffer(),"",0);rn rn elsern rn success=true;rn rn rn 这是第一个update语句rn if (NULL!=mysql&&mysql->status==MYSQL_STATUS_READY)rn rn //用于查询rn int ret=0;rn ret=mysql_real_query(mysql,sql.GetBuffer(),sql.GetLength()); rn if(0!=ret) rn rn const char * err=mysql_error(mysql);rn CString errMsg;rn errMsg.Format("%s,%s",err,"修改收藏数失败");rn ::MessageBox(TuanGouDlgPtr->m_hWnd,errMsg.GetBuffer(),"",0);rn rn elsern rn success=true;rn rn rn 这是第二个update语句rn [/code]
mysql自定义函数执行出错
在mysql5.0里创建了一函数代码如下:rnDELIMITER $$;rnrnDROP FUNCTION IF EXISTS `newspaper`.`f_hzcode`$$rnrnCREATE FUNCTION `f_hzcode`() RETURNS char(1)rnBEGINrndeclare fpy char(1);rn declare pc char(1);rn declare cc char(4);rn set @fpy = UPPER(left(words,1));rn set @pc = (CONVERT(@fpy USING gbk));rn set @cc = hex(@pc);rn if @cc >= "8140" and @cc <="FEA0" thenrn beginrn select PY from tbl_py where hz>=@pc limit 1 into @fpy;rn end;rn end if;rn Return @fpy;rnEND$$rnrnDELIMITER ;$$rnrn执行查询:rnselect f_hzcode('在');rnrn出错提示:rn错误代码: 1318rnIncorrect number of arguments for FUNCTION newspaper.f_hzcode; expected 0, got 1rn(耗费 0 ms)rnrn什么原因???
mysql执行.sql文件出错
今天在公司用myqsl数据执行导入一份XXX.sql文件的时候,怎么导,都是错的,而且报了这样一个错误:ERROR 2006 (HY000) at line xx: MySQL server has gone away;百度了一下,才发现,原来遇到这样错误的朋友有好多,而且解决的办法大体都一样。以为为解决的办法: 方法一:        就是在安装mysql的目录的my.ini文件里,可以
MySQL下执行sql文件出错
[img=https://img-bbs.csdn.net/upload/201610/11/1476182912_829066.png][/img]rnrn[code=sql]rnCREATE DATABASE book_sc;rnrnUSE book_sc;rnrnCREATE TABLE customersrn(rn customer_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,rn name CHAR(60) NOT NULL,rn address CHAR(80) NOT NULL,rn city CHAR(30) NOT NULL,rn states CHAR(20),rn zip CHAR(10),rn country CHAR(20) NOT NULLrn);rnrnCREATE TABLE ordersrn(rn order_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,rn customer_id INT UNSIGNED NOT NULL REFERENCES customers(customer_id),rn amount FLOAT(6,2),rn date DATE NOT NULL,rn order_status CHAR(10),rn ship_name CHAR(60) NOT NULL,rn ship_address CHAR(80) NOT NULL,rn ship_city CHAR(30) NOT NULL,rn ship_state CHAR(20),rn ship_zip CHAR(10),rn ship_country CHAR(20) NOT NULLrn);rnrnCREATE TABLE booksrn(rn isbn CHAR(13) NOT NULL PRIMARY KEY,rn author CHAR(100),rn title CHAR(100),rn cat_id INT UNSIGNED,rn price FLOAT(4,2) NOT NULL,rn description VARCHAR(255)rn);rnrnCREATE TABLE categoriesrn(rn cat_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,rn cat_name CHAR(60) NOT NULLrn);rnrnCREATE TABLE order_itemsrn(rn order_id INT UNSIGNED NOT NULL REFERENCES orders(order_id),rn isbn CHAR(13) NOT NULL REFERENCES books(isbn),rn item_price FLOAT(4,2) NOT NULL,rn quantity TINYINT UNSIGNED NOT NULL,rn PRIMARY KEY (order_id, isbn)rn);rnrnCREATE TABLE adminrn(rn username CHAR(16) NOT NULL PRIMARY KEY,rn password CHAR(40) NOT NULLrn);rnrnGRANT SELECT, INSERT, UPDATE, DELETErnON book_sc.*rnTO book_sc@localhost IDENTIFIED BY '322816';rnrn[/code]
pycharm执行python出错
pycham执行python提示错误,但在终端执行没有问题。如下图:rn在pycharm中执行rn[img=https://img-bbs.csdn.net/upload/201609/12/1473649694_640305.png][/img]rn终端执行rn[img=https://img-bbs.csdn.net/upload/201609/12/1473649684_563444.png][/img]rnrn哪位大神知道怎么回事?
重新执行初始化文件——source命令
source命令又叫“点命令”,重新执行刚修改的初始化文件,使之生效。 source
pycharm连接MySQL出错
出错: java.lang.RuntimeException: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must...
mysql连接出错
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets fr
jdbc连接mysql出错
public Connection generateConnection() throws DataException rn rn String strDbName="imhrs";rn String strUserName="root";rn String strPassWord="root";rn rn String strSQL="jdbc:mysql://localhost/"+strDbName;rn rn Connection connection=null;rn tryrn try rn Class.forName("org.gjt.mm.mysql.Driver").newInstance();rn catch (InstantiationException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn System.out.println("mysqljdbcConection.............................error.....");rn catch (IllegalAccessException e) rn // TODO Auto-generated catch blockrn System.out.println("mysqljdbcConection.............................error.....");rn e.printStackTrace();rn rn connection=DriverManager.getConnection(strSQL,strUserName,strPassWord);rn rn catch (ClassNotFoundException e) rn // TODO �Զ���� catch ��rn e.printStackTrace();rn catch (SQLException e) rn // TODO �Զ���� catch ��rn e.printStackTrace();rn rn rn return connection;rn rn rn这是链接代码rn下面的是报的错:rnAccess denied for user 'imhrs'@'localhost' (using password: YES)rn 这个错误的含义是什么了,还有就是 using password:YES这句话的意思是什么了。rn
eclipse连接mysql出错
![图片说明](https://img-ask.csdn.net/upload/201704/23/1492922645_61012.png)nn![图片说明](https://img-ask.csdn.net/upload/201704/23/1492922654_916799.png)nn这段代码图片放不上去 就复制下nnpackage com.buy.bean.comm.database;nimport java.sql.Connection;nimport java.sql.DriverManager;nimport java.sql.SQLException;nimport java.sql.Statement;nnpublic class DBConnect n n public static Connection getConnection() //获得数据库连接n Connection conn = null; //建立连接,初值为空n try n Class.forName(Config.CONNECTION_DRIVER).newInstance();n //获得配置文件的接口n conn = DriverManager.getConnection(Config.CONNECTION_URL, //取得连接n Config.CONNECTION_USER, Config.CONNECTION_PWD);n catch (Exception e) n e.printStackTrace(); //如果出错抛出异常n n if(conn == null) n System.out.println("no get connection! thrwos Exception");n //如果没有取得连接打印信息n n return conn; //返回连接n nnn```n n```nnnn![图片说明](https://img-ask.csdn.net/upload/201704/23/1492922419_806304.png)nn密码没有错 刚开始打项目 不太懂 希望帮忙下。
连接MySQL出错
我用如下方式连MySQL:rnmysql -h 192.168.1.104 -u root -prn出现如下错误:::rnerror 1130 (00000):#HY000Host 'user-ad0a4beb75' is not allowed to connect to this MySQL server.rn请问是什么原因.rnrnOS:windowsXP + SP2rnMYSQL:4.1.11rnrn上面的方法是本机连.IP改用localhost就可以正常连接.连其他人的机器也是同样的错误.4.1以下版本也是一样.
连接mysql出错
我用的是mysql4.1,如果不给root@localhost设置密码时,客户工具就能连上rn去,如果设密码,就出现以下错误。好像mysql4.1以前没有这个问题.真的不能设rn密码吗?rnrn[mysql] ERROR 1249: Client does not support authentication protocol requested by server. Consider upgrading MySQL client
PDO连接MySQL出错
getMessage()." ";rn rn?>rn运行时显示could not find driverrn修改了php.ini.dist和php.ini.recommended中的扩展,去掉了extension=php_mysql.dll、extension=php_pdo.dll和extension=php_pdo_mysql.dll前面的分号,重启了Apache,还是同样的错误,请大大帮帮忙阿
PHP连接MySQL出错
如题,本人刚开始学PHP,在搭建环境完成后,运行下面一段代码正常显示出PHP的信息,rn[code=PHP]rnrn[/code],rn但是下面代码IE也不报错,直接显示“该页无法显示”。rn[code=PHP][/code]rn密码都没错,而且php的配置把下面的都打开了(就是分号去掉了)rnextension=php_curl.dllrnextension=php_gd2.dllrnextension=php_mbstring.dllrnextension=php_mysql.dllrnextension=php_pdo_mysql.dllrnextension=php_pdo_odbc.dllrnextension=php_xmlrpc.dll rnrnrn请问下各位怎么回事,谢谢
JNDI连接mysql出错
大家好:rnrn我用JDNI连接Mysql,配置的context.xml如下rnrnrn rnrnrnrn报了下列错误rnCannot create PoolableConnectionFactory (Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "3306:tree"'.)rnrn和rnCannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "3306:tree"'.rnrn和rnCannot create PoolableConnectionFactory (Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: "3306:tree"'.)rn说是输入的字符串有问题,但看看context.xml感觉没有什么问题,很困惑,希望大家能指点迷津?
客户端连接mysql出错
3人阅读如果你想连接你的mysql的时候发生这个错误:ERROR 1130: Host '192.168.16.145' is not allowed to connect to this MySQL server改表法。可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "...
求救!MySql连接出错
我在连接MySql数据库时报以下错误,请各位大哥帮忙rnrnCaused by: java.sql.SQLException: Invalid authorization specification message from server: "Access denied for user: 'root'@'localhost' (Using password: YES)"
php连接MySQL出错
小弟刚学php,很多都不懂的。麻烦大神再帮我看看,我改了之后还是错。rn代码: $dbc = mysql_connect('localhost','tom', '123123', 'aliendatabase')rn or die('Error connecting to MySQL server.');rn $query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .rn "how_many, alien_description, what_they_did, fang_spotted, other, email) " .rn "VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .rn "'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";rn $result = mysql_query($dbc, $query)rn or die('Error querying database.');rn mysql_close($dbc);rnrn错误:Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22rnError connecting to MySQL server.rnrn我用的是Microsoft SQL Server 2005,我的SQL是连接服务器的了,用户名和密码也没有错。求解。
连接mysql出错,求教!
javax.servlet.ServletException: IOException:java.sql.SQLException: Communication link failure: java.io.IOException, underlying cause: Unexpected end of input streamrnrn** BEGIN NESTED EXCEPTION ** rnrnjava.io.IOExceptionrnMESSAGE: Unexpected end of input streamrnrnSTACKTRACE:rnrnjava.io.IOException: Unexpected end of input streamrn at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:1096)rn at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:626)rn at com.mysql.jdbc.Connection.createNewIO(Connection.java:1562)rn at com.mysql.jdbc.Connection.(Connection.java:491)rn at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)rn at java.sql.DriverManager.getConnection(DriverManager.java:525)rn at java.sql.DriverManager.getConnection(DriverManager.java:171)rn
scrapy连接mysql出错
报错内容大概是:connection localhost(无法连接localhost)         忘记截图。。。。。只把解决方法写进了txt         settings.py文件中的设置:                                                                    pipeline.py文件中连接数据库的设置:
MFC连接mysql出错
error LNK2019: 无法解析的外部符号 _mysql_real_connect@32,该符号在函数* 中被引用 error LNK2019: 无法解析的外部符号 _mysql_query@8,该符号在函数 * 中被引用 error LNK2019: 无法解析的外部符号 _mysql_init@4,该符号在函数 * 中被引用 error LNK2019: 无法解析的外部符号 _m
连接mysql运行时出错
[color=#FF0000]org.apache.commons.dbcp.SQLNestedException:Cannot create JDBC driver of class'' for connect URL'null',cause:rnjava.lang.NullPointerExceptionrn at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)[/color]rnrnrn我在连接mysql的时候出现的错误rn请各位高手指教这是怎么回事.
连接MySQL出错,急!!
我的源代码是这样的:rn<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>rnrnrnrn rn 连接My SQLrnrnrnrn<%@rnConnection conn=null;rntryrn Class.forName("com.mysql.jdbc.Driver").newInstance();rn conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","890910" ); rn if (!conn.isClosed()) out.print("已成功连接数据库 ");rn rncatch (SQLException ex)rn out.println(ex.getMessage());rn rnfinallyrn tryrn if (conn!=null) conn.close();rn rn catch (Exception ex)rn rn rn%>rn rnrnrn运行时出错了,错误信息如下(Tomcat 5.5的,JDK 1.5的,mysql 6.0的,rnrnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: /connectMySQL.jsp(11,0) Invalid directivern org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)rn org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)rn org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)rn org.apache.jasper.compiler.Parser.parseDirective(Parser.java:527)rn org.apache.jasper.compiler.Parser.parseElements(Parser.java:1568)rn org.apache.jasper.compiler.Parser.parse(Parser.java:132)rn org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)rn org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)rn org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.rnrnrnrnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: Unable to load class for JSPrn org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:599)rn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rnrnrnroot cause rnrnjava.lang.ClassNotFoundException: org.apache.jsp.connectMySQL_jsprn java.net.URLClassLoader$1.run(Unknown Source)rn java.security.AccessController.doPrivileged(Native Method)rn java.net.URLClassLoader.findClass(Unknown Source)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)rn org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)rn org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)rn org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:137)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:729)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 logs.rnrnrnrnrnUnable to load class for JSP 这句是不是说驱动程序加载不了?我的驱动是mysql-connector-java-5.1.7-bin.jar,在rnC:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib 和 rnC:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\myjsp\WEB-INF\lib 都有,在系统变量CLASSPATH里面有它的绝对路径 rnE:\lib\mysql-connector-java-5.1.7-bin.jar ,可是为什么还是出现了上面的错误,应该不会加载不了啊,好奇怪。搞了好久还是没弄好,哪位高手帮帮忙啊?感激不尽。。rn
php 连接mysql出错
在服务器上运行mysql,用我建立的用户登录,可以正确使用,完全正常。 rn但在PHP语句中写入:mysql_connect( "localhost","lijiang","1234"); rnrn就会报错误:rnWarning: mysql_connect() [function.mysql-connect]: Access denied for user 'lijiang'@'localhost' (using password: YES) in I:\AppServ\www\php\php\mysql_contect.php on line 10rnCould not connect: Access denied for user 'lijiang'@'localhost' (using password: YES)rnrn这是怎么回事呢?!谢谢 rn
grails连接mysql出错
刚刚开始研究grails,遇到一个问题:rn Error 2012-05-30 21:09:19,691 [pool-7-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rnMessage: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn Line | Methodrn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.ThreadrnrnCaused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.ThreadrnrnCaused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.ThreadrnrnCaused by BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.ThreadrnrnCaused by BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:rnPropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.ThreadrnrnCaused by PropertyBatchUpdateException: Failed properties: Property 'driverClassName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [com.mysql.jdbc.Driver]rn->> 303 | innerRun in java.util.concurrent.FutureTask$Syncrn- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - rn| 138 | run in java.util.concurrent.FutureTaskrn| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Workerrn| 908 | run in ''rn^ 619 | run . . in java.lang.Threadrnrnrn请高手帮忙解答一下,,mysql驱动已经放在lib目录下
servlet连接mysql出错
package com.user.CL;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnrnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnimport java.sql.*;rnpublic class LoginClServlet extends HttpServlet rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn rn request.setCharacterEncoding("utf-8");rn String id = request.getParameter("id");rn String password = request.getParameter("password");rn rn //声明变量rn Connection ct = null;rn ResultSet rs = null;rn PreparedStatement ps = null;rn rn //到数据库验证rn try rn //1.加载驱动rn Class.forName("com.mysql.jdbc.Driver");rn //2.得到链接rn ct=DriverManager.getConnection("jdbc:mysql://localhost:3066/qq","","");rn //3.创建PreparedStatementrn ps = ct.prepareStatement("select * from webuser where id=? and Password=?");rn //给?赋值rn ps.setObject(1, id);rn ps.setObject(2, password);rn //4.执行操作rn rs=ps.executeQuery();rn //5.根据结果处理rn if (rs.next()) rn //说明该用户合法rn request.getRequestDispatcher("/Main").forward(request, response);rn else rn request.setAttribute("err", "用户名或者密码出错!");rn request.getRequestDispatcher("/Login").forward(request, response);rn rn catch (Exception e) rn // TODO: handle exceptionrn e.printStackTrace();rn finallyrn //关闭资源rn if (rs!=null) rn try rn rs.close();rn catch (SQLException e2) rn // TODO: handle exceptionrn e2.printStackTrace();rn rn rs=null;rn rn if (ps!=null) rn try rn ps.close();rn catch (SQLException e) rn // TODO: handle exceptionrn e.printStackTrace();rn rn ps=null;rn rn if (ct!=null) rn try rn ct.close();rn catch (SQLException e) rn // TODO: handle exceptionrn e.printStackTrace();rn rn ct=null;rn rn rn rn rn rn rn rn /* if ("eason".equals(username)&&"123".equals(password)) rn response.sendRedirect("/UserManger/Main");rn else rn response.sendRedirect("/UserManger/Login");rn */rn rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn this.doGet(request, response);rn rnrnrn
jsp连接mysql出错
org.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 21 in the jsp file: /dbaccess.jsprncom.mysql.jdbc.Driver cannot be resolved to a typern18: //加载驱动程序,下面的代码加载MySQL驱动程序rn19: Class.forName("com.mysql.jdbc.Driver");rn20: //注册MySQL驱动程序rn21: DriverManager.registerDriver(new com.mysql.jdbc.Driver());rn22: //用适当的驱动程序连接到数据库rn23: String dbUrl = "jdbc:mysql://localhost:3306/BookDB?useUnicode=true&characterEncoding=GB2312";rn24: String dbUser="root";rnrnrnStacktrace:rn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)rn org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rnrnrn<%rn Connection con;rn Statement stmt;rn ResultSet rs;rn //加载驱动程序,下面的代码加载MySQL驱动程序rn Class.forName("com.mysql.jdbc.Driver");rn //注册MySQL驱动程序rn DriverManager.registerDriver(new com.mysql.jdbc.Driver());rn //用适当的驱动程序连接到数据库rn String dbUrl = "jdbc:mysql://localhost:3306/BookDB?useUnicode=true&characterEncoding=GB2312";rn String dbUser="root";rn String dbPwd="1234";rn //建立数据库连接rn con = java.sql.DriverManager.getConnection(dbUrl,dbUser,dbPwd);rn rn%>
spring mysql连接出错
这是在使用MySQL 8.0以上版本(MySQL连接驱动和版本都是8.0以上)的时候出现的问题错误,我们需要在访问数据库的Url后面加上以下的语句即可: ?serverTimezone=GMT%2B8 //比如,我原来的url是:&quot;jdbc:mysql://localhost:3306/shiro_test&quot; //应该修改为:&quot;jdbc:mysql://localhost:3306/shi...