sqlexception

String or binary data would be truncated exception?

我怕爱的太早我们不能终老 提交于 2019-12-07 18:52:08
问题 cmd = new SqlCommand("INSERT INTO sms_sentmessages(Mobilefrom,Mobileto,Message,senddate) VALUES('" + str.Substring(0, str.Length - 4).ToString() + "','" + number + "','" + txtmessage.Text.Replace("'", "''").Trim() + "',getdate())", con); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); 回答1: str.Substring(0, str.Length - 4) and/ or txtmessage.Text.Replace("'", "''").Trim() are too large to fit with the column you're trying to insert into. 回答2: Well, presumably you're trying to insert

How to create a scrollable ResultSet?

蹲街弑〆低调 提交于 2019-12-07 12:22:57
问题 I got this simple code to retrieve a recordset from a MSSQL Server 2008 which has to be scrollable due to the fact that I set the ResultSet.TYPE_SCROLL_INSENSITVE, same as the example from the Javadocs: String qry = "SELECT * from tblPeople"; SQLConnection sql = new SQLConnection(); Statement stmt = sql.getConnection().createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(qry); Unfortunately I still got this Stack Trace when I want

java.sql.SQLException: No value specified for parameter 2

拜拜、爱过 提交于 2019-12-07 09:00:06
问题 I have here my code for login and I am encountering this error, "java.sql.SQLException: No value specified for parameter 2" sometimes, "java.sql.SQLException:Parameter index out of range (1> number of parameters, which is 0)." I really don't have any idea. import java.sql.*; import javax.swing.*; public class Login_form extends javax.swing.JFrame { Connection conn=null; ResultSet rs = null; PreparedStatement pst = null; public Login_form() { initComponents(); conn=javaconnect.ConnecrDb(); } /

Fixed Cannot open database requested by the login. The login failed

早过忘川 提交于 2019-12-06 16:16:18
I try to execute this web application but it gave me this error messages when I try to register a user account in the web application: System.Data.SqlClient.SqlException occurred HResult=0x80131904 Message=Cannot open database "rentalsystem" requested by the login. The login failed. Login failed for user 'MicrosoftAccount\corene100@outlook.com'. Source=.Net SqlClient Data Provider I look up online and try any of the solutions stated but still this error pops up every time I try to click the register button. I already created a user login for MicrosoftAccount\corene100@outlook.com (using

Timeout exception when using NHibernate TransactionScope

倖福魔咒の 提交于 2019-12-06 09:20:21
This is continuation of Timeout exception when timeout set to infinite time (and I also see unanswered SqlConnection and TransactionScope Timeout question). I am using CastleProject ActiveRecord over NHibernate, C# 3.5. I have multiple subsequent inserts to a database within TransactionScope. One of them (random, different each time) fails with TimeoutException. Whichever timeout I set in my config file (10 hours), this does not matter. If I do not use transaction scope, it work (but too slow). It seems, NHibernate transaction has default timeout 30 second and is not affected by hibernate

Why is Hibernate throwing a SQLGrammarException saying table/view does not exist when I've set hbm2ddl.auto to create?

廉价感情. 提交于 2019-12-06 07:30:25
问题 I've been experimenting with hibernate and spring and servlets. Now, I'm stuck. Why am I getting this exception? I thought tables would be created automatically when hbm2ddl.auto is set to create. appicationContext.xml <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver" /> <property name="url" value="jdbc:derby://localhost:1527/db;create=true" /> </bean> <bean id="sessionFactory"

SqlException ErrorCodes

余生长醉 提交于 2019-12-06 07:28:58
I have a question, and it is not a problem. My database have some restrictions, as unique names (Column that stores the name of something that must be unique) When inserting or updating, the db verifies if we are not overriding some name, and if so, returns an error that is convertable to SqlException with code 2627 My Question is... if exists some table or something that I can consult to indicate to the final user what to do? In this case.. that exists a user with the same name.... I think, you should take a look at SqlExceptions Errors property and take a look at errors number which should

Is there a 64bit driver for Microsoft Access?

孤街醉人 提交于 2019-12-06 03:33:14
java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application I get the following error when I try to connect to my Microsoft Access database from an eclipse project using jdbc. I am using 64bit windows and microsoft office 2007. any help on this matter would be great. Access 2010 has 64 bit drivers and can be downloaded http://www.microsoft.com/downloads/details.aspx?FamilyID=C06B8369-60DD-4B64-A44B-84B371EDE16D&displaylang=en 64bit applications can't play with the 32bit Jet (Access) drivers. You need to fix this

How to create a scrollable ResultSet?

余生长醉 提交于 2019-12-05 23:44:00
I got this simple code to retrieve a recordset from a MSSQL Server 2008 which has to be scrollable due to the fact that I set the ResultSet.TYPE_SCROLL_INSENSITVE, same as the example from the Javadocs: String qry = "SELECT * from tblPeople"; SQLConnection sql = new SQLConnection(); Statement stmt = sql.getConnection().createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(qry); Unfortunately I still got this Stack Trace when I want to get the row count like rs.last(); int rowCount = rs.getRow(); : java.sql.SQLException: ResultSet may

java.sql.SQLException: No value specified for parameter 2

一曲冷凌霜 提交于 2019-12-05 17:22:18
I have here my code for login and I am encountering this error, "java.sql.SQLException: No value specified for parameter 2" sometimes, "java.sql.SQLException:Parameter index out of range (1> number of parameters, which is 0)." I really don't have any idea. import java.sql.*; import javax.swing.*; public class Login_form extends javax.swing.JFrame { Connection conn=null; ResultSet rs = null; PreparedStatement pst = null; public Login_form() { initComponents(); conn=javaconnect.ConnecrDb(); } // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jPanel1