sqlexception

How to catch SqlException caused by deadlock?

老子叫甜甜 提交于 2019-11-29 20:01:02
From a .NET 3.5 / C# app, I would like to catch SqlException but only if it is caused by deadlocks on a SQL Server 2008 instance. Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Yet, it does not seem to be a documented error code for this exception. Filtering exception against the presence of the deadlock keyword in their message seems a very ugly way to achieve this behavior. Does someone know the right way of doing this? AdaTheDev The Microsft SQL Server-specific

SqlException: System.Data.SqlClient.SqlException (0x80131904)

谁说我不能喝 提交于 2019-11-29 16:07:57
I wrote a code in C#, which works great at my computer, with Windows 7 (MS SQL Server 2008) but not at the other with Windows Vista (MS SQL Server 2005). I can not change system on the second computer ;) I'm using Visual Studio 2010. So this is the part of code, from my class "obSQL": private SqlConnection connection; public obSQL(string user, string pass, string instance, string dbdir) //sql server authentication { connection = new SqlConnection(); connection.ConnectionString = "user id=" + user + ";" + "password=" + pass + ";Data Source=" + instance + ";" + "Trusted_Connection=no;" +

Jdbc Hive2 Invalid Url Exception

对着背影说爱祢 提交于 2019-11-29 14:37:43
I have a Hortonwork cluster (Linux) and want to use JDBC for loading data into Hive from a remote host. I am trying to get the JDBC connection to work locally on the cluster first so that I know I have done it correct before trying remotely. Hive has been succesfully installed and I can connect through beeline without any problems: /usr/lib/hive/bin/beeline Beeline version 0.13.0.2.1.4.0-632 by Apache Hive beeline> !connect jdbc:hive2://localhost:10000 scan complete in 3ms Connecting to jdbc:hive2://localhost:10000 Enter username for jdbc:hive2://localhost:10000: someuser Enter password for

CommunicationsException: Communications link failure

一笑奈何 提交于 2019-11-29 11:17:55
I used java to query some records from Mysql. But in some querys of one duration, i meet a problem which make query failed, but in others , it query successful. The error message is next: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet successfully received from the server was 90 milliseconds ago. The last packet sent successfully to the server was 1,674 milliseconds ago. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at

How is SqlException Number assigned

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 00:22:30
SqlException has the property Number . Then there is this: http://msdn.microsoft.com/en-us/library/cc645603.aspx and this: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx And it seems to be one or the other QUESTION: How is it decided which? REASON FOR ASKING: I need to catch certain SqlExceptions and decide how to deal with them based on the Number property but I don't know which list I should look at when it seems like the system is using messages from both, and I don't know what criteria is used for choosing. For example: Number 53 - from server error message

How to catch SqlException caused by deadlock?

陌路散爱 提交于 2019-11-28 14:59:36
问题 From a .NET 3.5 / C# app, I would like to catch SqlException but only if it is caused by deadlocks on a SQL Server 2008 instance. Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Yet, it does not seem to be a documented error code for this exception. Filtering exception against the presence of the deadlock keyword in their message seems a very ugly way to achieve this

Procedure times out from ADO.NET but not in SSMS

落爺英雄遲暮 提交于 2019-11-28 13:59:59
I've got a stored procedure that is giving me a SqlException because of a timeout when I run it from code (with timeout set to 30). When I run the procedure directly in Management Studio, it executes in under 1 second. I also only get the timeout when running it against a specific database. When I use other databases it finishes quickly without an error. Here is the full error message: System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlConnection.OnError

architecture mismatch between the Driver and Application?

北城余情 提交于 2019-11-28 12:26:11
I am using JDBC to connect to my microsoft access database. I get the following exception when I try to connect to the database: java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application I am using 64bit windows7, and I am using eclipse which is also a 64bit version My database is a microsoft access database and it seems that the driver is a 32bit driver which is causing the problem. Any help on how to solve this problem would be greatly appreciated. Check out the access 2010 redist Microsoft Access Database

How to throw a SqlException when needed for mocking and unit testing?

半世苍凉 提交于 2019-11-28 06:07:50
I am trying to test some exceptions in my project and one of the Exceptions I catch is SQlException . It seems that you can't go new SqlException() so I am not sure how I can throw an exception especially without somehow calling the database (and since these are unit tests it is usually advised not to call the database since it is slow). I am using NUnit and Moq, but I am not sure how to fake this. Responding to some of the answers that seem to all be based on ADO.NET, note that I am using Linq to Sql. So that stuff is like behind the scenes. More info as requested by @MattHamilton: System

Receiving SQLException “Login failed for user” connecting to SQL Server 2008

ε祈祈猫儿з 提交于 2019-11-28 03:39:25
问题 I am trying to connect to SQL Server 2008 via Java. I've added sqljdbc4.jar to my project's library. No username and password is set for database accessing the database (Windows Authentication). The 1433 port is Listening, but I still receive this exception: SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ''. ClientConnectionId:085d5df3-ad69-49e1-ba32-b2b990c16a69 Relevant code: public class DataBases { private Connection link; private java.sql.Statement