sqlexception

CommunicationsException: Communications link failure

一个人想着一个人 提交于 2019-12-18 06:40:07
问题 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

How is SqlException Number assigned

放肆的年华 提交于 2019-12-18 02:57:32
问题 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,

java.sql.SQLException: Operation not allowed after ResultSet closed MySQL Java

 ̄綄美尐妖づ 提交于 2019-12-17 21:37:19
问题 I keep getting this whenever I try to use this method. java.sql.SQLException: Operation not allowed after ResultSet closed at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:794) at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7077) at server.util.Plimus$1.run(Plimus.java:77) This

Ambiguous column name error

点点圈 提交于 2019-12-17 16:56:13
问题 When executing the following (complete) SQL query on Microsoft SQL Server 2000: SELECT B.ARTIFACTTNS, B.ARTIFACTNAME, B.ARTIFACTTYPE, B.INITIALBYTES, B.TIMESTAMP1, B.FILENAME, B.BACKINGCLASS, B.CHARENCODING, B.APPNAME, B.COMPONENTTNS, B.COMPONENTNAME, B.SCAMODULENAME, B.SCACOMPONENTNAME FROM (SELECT DISTINCT A.ARTIFACTTYPE, A.ARTIFACTTNS, A.ARTIFACTNAME FROM (SELECT DISTINCT ARTIFACTTYPE, ARTIFACTTNS, ARTIFACTNAME FROM CUSTPROPERTIES WHERE PNAME = 'AcmeSystemName' AND PVALUE = 'MyRuleGroup'

Obtain the Query/CommandText that caused a SQLException

微笑、不失礼 提交于 2019-12-17 16:44:09
问题 I've got a logger that records exception information for our in house applications. When we log SQL exceptions it'd be super useful if we could see the actual query that caused the exception. Is there a way we can achieve this? 回答1: The SqlException does not hold a reference to the SqlCommand that caused the exception. In your logger there is no way to do this. What you could do is catch the SqlException in the method that executes the SqlCommand and wrap it in a more descriptive exception.

How to know actual problem because of which SqlException is thrown?

江枫思渺然 提交于 2019-12-17 14:02:09
问题 I want to handle different problems, while doing database operations, differently. e.g. The operation may fail because of wrong database credentials or due to network problem. Or it may fail because the query is not correct (if string value is being passed in the int type column) In my C# code, we only have SqlException which has collection of SqlErrors . However there are many severity levels. How can i easily identify the cause of the SqlException ? How can i determine the exception is

java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F…'

旧街凉风 提交于 2019-12-17 03:49:49
问题 I have the following string value: "walmart obama 👽💔" I am using MySQL and Java. I am getting the following exception: `java.sql.SQLException: Incorrect string value: '\xF0\x9F\x91\xBD\xF0\x9F...' Here is the variable I am trying to insert into: var1 varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL` My Java code that is trying to insert "walmart obama 👽💔" is a preparedStatement. So I am using the setString() method. It looks like the problem is the encoding of the values 👽💔.

java.sql.SQLException: Column count doesn't match value count at row 1

怎甘沉沦 提交于 2019-12-17 02:00:15
问题 The structure of my table: id int AUTO_INCREMENT PRIMARY KEY title text url text age int Here's how I am trying to save data into this table: PreparedStatement ps=con.prepareStatement("insert into table(title, url, age) values ('\"+title+\",\"+url+\",\"+age+\"')"); System.out.println("Connected database successfully.."); ps.executeUpdate(); But when I run the app, I get java.sql.SQLException: Column count doesn't match value count at row 1 I guess the problem might be in the id column, how to

Derby foreign key constraint

风流意气都作罢 提交于 2019-12-13 19:01:20
问题 What's the problem with this statement that gives me the following exception? s.addBatch("CREATE TABLE category ( id SMALLINT NOT NULL GENERATED ALWAYS AS IDENTITY \n" + "\t(START WITH 0, INCREMENT BY 1), title VARCHAR(100))\n" ); s.addBatch("CREATE TABLE task (id SMALLINT NOT NULL GENERATED ALWAYS AS IDENTITY \n" + "\t(START WITH 0, INCREMENT BY 1), title VARCHAR(100), cat_id INT, visible BOOLEAN, " + "deprecated BOOLEAN" + "CONSTRAINT fk_cat_id FOREIGN KEY (cat_id)\n" + "\tREFERENCES

Why I cannot debug a DatabaseMetaData?

随声附和 提交于 2019-12-12 19:02:47
问题 I've a strange situation with a little application in Java using a JDBC-OBDC. I'm inspecting a Database using the DatabaseMetaData Class. When I execute the program, everything works without anyproblem. But when I want to debug to see the values inside the Resulset containing the DatabaseMetaData a java.sql.SQLException is thrown only if I put a breakpoint within the while. Here's my code: DatabaseMetaData patrol = con.getMetaData(); ResultSet answer = patrol.getTables(null, null, null, null)