设为首页 收藏本站
查看: 1002|回复: 0

[经验分享] SQL连接异常总结

[复制链接]

尚未签到

发表于 2016-11-11 04:47:44 | 显示全部楼层 |阅读模式
DSC0000.gif 异常:

Class.forName(DBDRIVER);
            conn 
= DriverManager.getConnection(DBURL,DBUSERNAME,DBPASSWORD);
            stmt 
= conn.createStatement();
            sql 
= "SELECT name FROM userInformation WHERE id='"+username+"' and password='"+password+"'";
            rs 
= stmt.executeQuery(sql);
            
if(rs.next())
            {
                flag 
= true;
            }
            rs.
close();
            stmt.
close();
            conn.
close();

代码出现类似”
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'userInformation’无效。”异常
解决方法:控制台根目录\Microsoft SQL Server\SQL Server 组\(local)(Windows NT)\安全性\登陆修改sa账户默认数据库为你使用的数据库.还可西新建数据库,选择默认数据库为你使用的数据库


异常:
    SQLServer2000默认连接端口为1434端口,有时连接异常时可能是端口被占用的缘故,可以通过修改端口解决,
    解决方法:服务器网络实用工具\常规\启用协议,选择TCP/IP属性修改端口即可,服务器需要重启.

异常:

jsp页面中表单提交的中文数据编码格式要转换成gb2312后,再插入到数据库。 String after=new String(before.getBytes("iso-8859-1"),"gb2312"); before为原始中文数据,after是经过转换后要提交到数据库里的数据。
异常:
    SQLServer 2000中如何设置向Access一样的ID自动编号
出现异常:SQLServer 缺少列数,列数不匹配
选中ID列,设置数据类项为(int/number)列属性里设置标识为是,标识种子为1,表示增量为1

异常:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]将截断字符串或二进制数据。
多半是由于段长度大小的问题,你插入的内容的长度大于该字段定义的长度

异常
[Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
检查你的数据库服务器有没有开启,端口是否占用,配置是否正确,其次看看下面的异常处理
"Error establishing socket" exception while connecting to the database
Symptom: while running a windows application that includes massive opening and closing of a connections to database server, "Error establishing socket" exception appears after a short time of execution. 
Cause: This problem is caused by a lack of a reusable sockets on client machine, since each TCP/IP connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in this state, the socket cannot be reused. 
Resolution: do one of the following: 
Increase the port range that is used for anonymous ports to approximately 20,000 ports (for example) by modifying the MaxUserPort registry key (this parameter controls the maximum port number that is used when an application requests any available user port from the system). Windows uses the conventional BSD range of 1024 to 5000 for its anonymous (ephemeral) port range. You can set only the upper bound of the ephemeral port range. To modify the MaxUserPort registry key, follow these steps: 
Start Registry Editor (Regedt32.exe). Please note that you should backup your registry and any important files on your computer before editing the registry. 
Locate the MaxUserPort key in the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters 
On the Edit menu, click Add Value, and then add the following registry value: 
Value Name: MaxUserPort 
Data Type: REG_DWORD 
Value: 65534 (for example) 
Valid Range: 5000-65534 (decimal) 
Default: 0x1388 (5000 decimal) 
Quit Registry Editor. 
Change the timeout on the connections from 240 seconds (the default) to any length from 30 seconds to 300 seconds. Use the TcpTimedWaitDelay registry parameter to change this value. To do this, start Registry Editor (Regedt32.exe), locate the following key in the registry, and then modify the value HKEY_LOCAL_MACHINE\System\CurrectControlSet\services\Tcpip\Parameters (this parameter determines the length of time that a connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be reused. For more information, see RFC 793): 
Value Name:TcpTimedWaitDelay 
Value Type: REG_DWORD-time in seconds 
Valid Range: 30-300 (decimal) 
Default: 0xF0 (240 decimal) 

异常:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid parameter binding(s).

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]将截断字符串或二进制数据。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-298509-1-1.html 上篇帖子: Transact-SQL语言-存储过程 下篇帖子: T-SQL 触发器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表