sqlexception

C# try catch confusion

淺唱寂寞╮ 提交于 2021-02-07 12:49:18
问题 I'm very new to C#. When I try catch something like this: try { connection.Open(); command.ExecuteNonQuery(); } catch(SqlException ex) { MessageBox.Show("there was an issue!"); } How do I know if the problem happened with the Open or ExecuteNonQuery ? What if I called a bunch of other non-SQL stuff in the Try ? How would I know which failed? What does SqlException mean over regular Exception ? How would SqlException handle non-SQL related errors if I had such code in the Try block? 回答1: You

jdbc to MYSQL error: “table airportdetails doesn't exist”

你。 提交于 2021-01-29 04:59:22
问题 I am trying to connect to a MySQL database from a jsp page using jdbc in the backend. I have the following code: public static void insertIntoDatabase(String code,String name,String temp,String hum,String del) { Connection con = null; if (del.length() == 0) { del="no data"; } name = name.replaceAll("\\(.+?\\)", ""); name = name.replaceAll(" ", "_"); del = del.replaceAll(" ", "_"); System.out.println("del "+del); String url = "jdbc:mysql://localhost:3306/test"; try { Class.forName("com.mysql

Ucanaccess SQL Exception: feature not supported (Access and Netbeans)

China☆狼群 提交于 2020-05-09 05:26:05
问题 I've been researching this problem for days and have decided to ask this question here to see if anyone can help point me in the right direction. I'm trying to populate combo boxes in my Netbeans 8.0.2 program with data from an MS Access 2013 table. I'm using the most recent "Ucanaccess" with all of its necessary components to get the connection between the two, and from what I can tell the connection is good. However, when I run the program, it pops up an error exception message, reading:

jdbc to MYSQL error: No suitable driver found for jdbc:mysql://localhost:3306/test?user='root'&password='' [duplicate]

杀马特。学长 韩版系。学妹 提交于 2020-01-22 02:24:07
问题 This question already has answers here : The infamous java.sql.SQLException: No suitable driver found (13 answers) Closed 3 years ago . I have the following code to connect to a mysql db : public static void insertIntoDatabase(String code,String name,String temp,String hum,String del) { Connection con = null; ResultSet rs = null; String url = "jdbc:mysql://localhost:3306/test"; String user = "root"; String password = ""; try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager

ResultSet.getString(1) throws java.sql.SQLException: Invalid operation at current cursor position

随声附和 提交于 2020-01-18 04:44:08
问题 When I run the following servlet: // package projectcodes; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { String UserID = request.getParameter("UserID"); String UserPassword = request.getParameter("UserPassword"); String userName = null; String Email = null; Encrypter encrypter = new Encrypter(); String hashedPassword = null; try { hashedPassword = encrypter.hashPassword(UserPassword); Context context = new InitialContext();

java.sql.SQLException: No suitable driver, when starting tomcat server

风流意气都作罢 提交于 2020-01-16 00:55:31
问题 I converted a running Java web project to Maven based project, everything works fine except starting the tomcat server from eclipse. I´m getting a strange SQLException: ... 19.06.2012 17:09:08 org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java 19.06.2012 17:09:08 org.apache

SqlConnection error Named Pipes Provider

纵饮孤独 提交于 2020-01-14 05:18:07
问题 A little background: I have a Windows .NET application that is in use by approximately 40 field employees across North America. This program allows the users to enter data while in the field (away form internet access) and then synchronizes to our Sql Server 2005 database at night. A couple days ago, two of my users reported getting the following error when they performed an action that would attempt to connect to our server database (which uses .NET's SqlConnection class). System.Data

conversion of a varchar data type to a datetime data type resulted in an out-of-range value

邮差的信 提交于 2020-01-08 16:55:11
问题 I have the following piece of inline SQL that I run from a C# windows service: UPDATE table_name SET status_cd = '2', sdate = CAST('03/28/2011 18:03:40' AS DATETIME), bat_id = '33acff9b-e2b4-410e-baaf-417656e3c255', cnt = 1, attempt_date = CAST('03/28/2011 18:03:40' AS DATETIME) WHERE id = '1855' When I run this against a SQL Server database from within the application, I get the following error: System.Data.SqlClient.SqlException: The conversion of a varchar data type to a datetime data type

java.sql.SQLException: ResultSet closed on sqlite

只愿长相守 提交于 2020-01-05 05:57:11
问题 I looked at many answers but unfortunately none answers my question and I still can't figure this out why I'm getting ResultSet closed . Here is the try code snippet that`s causing the issue: System.out.println(" System Info! @CHKMD5Files(): Found pre-existing details: "+TOTAL); Statement stmMD5 = null; Connection connMD5 = null; ResultSet rs_MD5 = null; String RESULTMD5 = null; try { connMD5 = DriverManager.getConnection("jdbc:sqlite:" + bkpPATH+ hostname + ".db"); stmMD5 = connMD5

An error occured during the pre-login handshake

左心房为你撑大大i 提交于 2020-01-03 18:48:07
问题 I had a C# application that communicates with a database using Linq to SQL and was working just fine when I last tested it a month ago. However, it is now throwing the following exception: A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll ------ Exception ------ Error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The received certificate