Search Results

Search found 429 results on 18 pages for 'sqlexception'.

Page 10/18 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Database error when deleting entry in my rails app.

    - by Danny McClelland
    Hi Everyone...again! I have almost everything in my Rails app working, with the exception of detroying entries. I can destroy entries for companies but not kases and people. The following error show when trying to do so: SQLite3::SQLException: no such column: kases_people.kase_id: SELECT * FROM "kases" INNER JOIN "kases_people" ON "kases".id = "kases_people".kase_id WHERE ("kases_people".person_id = 5 ) I suspect this is an error with the party model for the has_many :through associations that I dont fully understand. You can find an up to date version of the app at www.github.com/dannyweb/surveycontrol Thanks, Danny

    Read the article

  • Should I catch exceptions thrown when closing java.sql.Connection

    - by jb
    Connection.close() may throw SqlException, but I have always assumed that it is safe to ignore any such exceptions (and I have never seen code that does not ignore them). Normally I would write: try{ connection.close(); }catch(Exception e) {} Or try{ connection.close(); }catch(Exception e) { logger.log(e.getMessage(), e); } The question is: Is it bad practice (and has anyone had problems when ignoring such exeptions). When Connection.close() does throw any exception. If it is bad how should I handle the exception. Comment: I know that discarding exceptions is evil, but I'm reffering only to exceptions thrown when closing a connection (and as I've seen this is fairly common in this case). Does anyone know when Connection.close() may throw anything?

    Read the article

  • Rails Habtm with a field

    - by moshimoshi
    Hello, Is that possible to have a field in a has and belongs to many table? Just like favorite: create_table :messages_users, :id => false, :force => true do |t| t.integer :message_id, :null => false t.integer :user_id, :null => false t.boolean :favorite, :null => false t.timestamps end I saw timestamps works well, thanks to ActiveRecord. But when I try to add favorite into the table and then I try: Message.first.users << User.first Then I get this error message: ActiveRecord::StatementInvalid: SQLite3::SQLException: messages_users.favorite may not be NULL: INSERT INTO "messages_users" ("created_at", "message_id", "updated_at", "user_id") VALUES ('''2010-05-27 06:07 :50.721512''', 1, '''2010-05-27 06:07:50.721512''', 1) I would like to use a habtm, I don't like has_many foo though bar association :) Is that possible? Thanks a lot.

    Read the article

  • cant use Activerecord find method with associations.

    - by fenec
    here are my models: #game class Game < ActiveRecord::Base #relationships with the teams for a given game belongs_to :team_1,:class_name=>"Team",:foreign_key=>"team_1_id" belongs_to :team_2,:class_name=>"Team",:foreign_key=>"team_2_id" def self.find_games(name) items = Game.find(:all,:include=>[:team_1,:team_2] , :conditions => ["team_1.name = ?", name] ) end end #teams class Team < ActiveRecord::Base #relationships with games has_many :games, :foreign_key =>'team_1' has_many :games, :foreign_key =>'team_2' end When i execute Game.find_games("real") i get : ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: team_1.name How can i fix the problem i thought that using :include would fix the problem.

    Read the article

  • Why Could Linq to Sql Submit Changes Fail for Updates Despite Data in Change Set

    - by KevDog
    I'm updating a set of objects, but the update fails on a SqlException that says "Incorrect Syntax near 'Where'". So I crack open SqlProfiler, and here is the generated SQL: exec sp_executesql N'UPDATE [dbo].[Addresses] SET WHERE ([AddressID] = @p0) AND ([StreetAddress] = @p1) AND ([StreetAddress2] = @p2) AND ([City] = @p3) AND ([State] = @p4) AND ([ZipCode] = @p5) AND ([CoordinateID] = @p6) AND ([CoordinateSourceID] IS NULL) AND ([CreatedDate] = @p7) AND ([Country] = @p8) AND (NOT ([IsDeleted] = 1)) AND (NOT ([IsNonSACOGZip] = 1))',N'@p0 uniqueidentifier,@p1 varchar(15),@p2 varchar(8000),@p3 varchar(10),@p4 varchar(2),@p5 varchar(5),@p6 uniqueidentifier,@p7 datetime,@p8 varchar(2)',@p0='92550F32-D921-4B71-9622-6F1EC6123FB1',@p1='125 Main Street',@p2='',@p3='Sacramento',@p4='CA',@p5='95864',@p6='725E7939-AEE3-4EF9-A033-7507579B69DF',@p7='2010-06-15 14:07:51.0100000',@p8='US' Sure enough, no set statement. I also called context.GetChangeSet() and the proper values are in the updates section. Also, I checked the .dbml file and all of the properties Update Check values are 'Always'. I am completely baffled on this one, any help out there?

    Read the article

  • How to manage db connections on server?

    - by simpatico
    I have a severe problem with my database connection in my web application. Since I use a single database connection for the whole application from singleton Database class, if i try concurrent db operations (two users) the database rollsback the transactions. This is my static method used: All threads/servlets call static Database.doSomething(...) methods, which in turn call the the below method. private static /* synchronized*/ Connection getConnection(final boolean autoCommit) throws SQLException { if (con == null) { con = new MyRegistrationBean().getConnection(); } con.setAutoCommit(true); //TODO return con; } What's the recommended way to manage this db connection/s I have, so that I don't incurr in the same problem.

    Read the article

  • Custom SQL function for NHibernate dialect

    - by Kristoffer Ahl
    I want to be able to call a custom function called "recent_date" as part of my HQL. Like this: [Date] >= recent_date() I created a new dialect, inheriting from MsSql2000Dialect and specified the dialect for my configuration. public class NordicMsSql2000Dialect : MsSql2000Dialect { public NordicMsSql2000Dialect() { RegisterFunction( "recent_date", new SQLFunctionTemplate( NHibernateUtil.Date, "dateadd(day, -15, getdate())" ) ); } } var configuration = Fluently.Configure() .Database( MsSqlConfiguration.MsSql2000 .ConnectionString(c => .... ) .Cache(c => c.UseQueryCache().ProviderClass<HashtableCacheProvider>()) .Dialect<NordicMsSql2000Dialect>() ) .Mappings(m => ....) .BuildConfiguration(); When calling recent_date() I get the following error: System.Data.SqlClient.SqlException: 'recent_date' is not a recognized function name I'm using it in a where statement for a HasMany-mapping like below. HasMany(x => x.RecentValues) .Access.CamelCaseField(Prefix.Underscore) .Cascade.SaveUpdate() .Where("Date >= recent_date()"); What am I missing here?

    Read the article

  • java jdbc connection to mysql problem

    - by fatnjazzy
    Hi, I am trying to connect to mysql from java web application in eclipse. Connection con = null; try { //DriverManager.registerDriver(new com.mysql.jdbc.Driver()); Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost/db_name","root" ,""); if(!con.isClosed()) System.out.println("Successfully connected to " + "MySQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: " + e.getMessage()); } finally { try { if(con != null) con.close(); } catch(SQLException e) { System.out.println(e.toString()); } } I am always getting the Exception: com.mysql.jdbc.Driver I have downloaded this jar http://forums.mysql.com/read.php?39,218287,220327 import it to the "java build path/lib" the mysql version is 5.1.3 under. running: mysql 5.1.3 (db is up and running queries form PHP) windows XP java jee Thanks

    Read the article

  • Simplest way of creating java next/previous buttons

    - by Holly
    I know that when creating buttons, like next and previous, that the code can be somewhat long to get those buttons to function. My professor gave us this example to create the next button: private void jbtnNext_Click() { JOptionPane.showMessageDialog(null, "Next" ,"Button Pressed", JOptionPane.INFORMATION_MESSAGE); try { if (rset.next()) { fillTextFields(false); }else{ //Display result in a dialog box JOptionPane.showMessageDialog(null, "Not found"); } } catch (SQLException ex) { ex.printStackTrace(); } } Though, I do not really understand how that short and simple if statement is what makes the next button function. I see that the fillTextFields(false) uses a boolean value and that you need to initialize that boolean value in the beginning of the code I believe. I had put private fillTextFields boolean = false; but this does not seem to be right... I'm just hoping someone could explain it better. Thanks :)

    Read the article

  • Timeout LinqToSql inserting millions of records

    - by Bas
    I'm inserting approximently 3 million records in a database using this solution. Eventually when the application has been inserting records for a while (my last run lasted around 4 hours), it gives a timeout with the following SqlException: "SqlExcepetion: Timeout expired. The timeoutperiod elapsed prior to completion of the operation or the server is not responding." What's the best way to handle this exception? Is there a way to prevent this from happening or should I catch the exception? Thanks in advance!

    Read the article

  • Stored procedure call in method with OperationBehavior attribute: problems with transactions

    - by Gerrie Schenck
    I'm using ADO.Net's ExecuteNonQuery to call a stored procedure, works like a charm stand-alone but when implementing it where it should be called I'm running into problems concerning transactions. For example System.Data.SqlClient.SqlException: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0. and also a timeout right after that. I've just found out the method which calls the stored procedure is marked with the following WCF attribute: [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)] How will this influence the call my stored procedure? How can I tell .Net to execute the stored procedure outside this transaction? The stored procedure contains insert statements and also a transaction, but removing them doesn't change the behavior...

    Read the article

  • How to debug Fluent nHibernate

    - by Matt Thrower
    Hi, I'm having some trouble with Fluent nHibernate. I added a column to a table and I thought I'd correctly changed the mappings and the connected data objects to correctly reflect this. However when I tried to run my application again I kept getting this error: System.Data.SqlClient.SqlException: Invalid column name 'Workflow_id'. I really couldn't see what the problem was with the changes I'd made so I reverted back to the original versions of the mapping and data object files from source control and removed the offending column from the database. But I'm still getting the same error. I'd like some advice on how to debug this. The SQL that gets reported on the error is semi-nonsensical: SELECT regions0_.Page_id as Page5_1_, regions0_.Id as Id1_, regions0_.Id as Id27_0_, regions0_.RegionId as RegionId27_0_, regions0_.RegionTemplate_id as RegionTe3_27_0_, regions0_.Workflow_id as Workflow4_27_0_ FROM [Region] regions0_ WHERE regions0_.Page_id=? And it won't execute as valid SQL anyway. Any ideas as to where to go from here?

    Read the article

  • acts-as-taggable-on: find tags with name LIKE, sort by tag_counts?

    - by James
    Hi I'm using the rails plugin acts-as-taggable-onand I'm trying to find the top 5 most used tags whose names match and partially match a given query. When I do User.skill_counts.order('count DESC').limit(5).where('name LIKE ?', params[:query]) This return the following error: ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: name: SELECT tags.*, COUNT(*) AS count FROM "tags" INNER JOIN users ON users.id = taggings.taggable_id LEFT OUTER JOIN taggings ON tags.id = taggings.tag_id AND taggings.context = 'skills' WHERE (taggings.taggable_type = 'User') AND (taggings.taggable_id IN(SELECT users.id FROM "users")) AND (name LIKE 'asd') GROUP BY tags.id, tags.name HAVING COUNT(*) > 0 ORDER BY count DESC LIMIT 5 But when I do User.skill_counts.first.name this returns "alliteration" I'd appreciate any help on this matter.

    Read the article

  • JDBC THIN Oracle with Java6

    - by Sopolin
    Hi all, I have a problem with JDBC Thin in Oracle 11g with NetBeans V6.7.1. I don't know how to configure it. I have already set classpath of ojdbc6.jar and orai18n.jar. But I still can't run this example in NetBeans: import java.sql.*; import oracle.jdbc.*; import oracle.jdbc.pool.OracleDataSource; class JDBCVersion { public static void main (String args[]) throws SQLException { OracleDataSource ods = new OracleDataSource(); ods.setURL("jdbc:oracle:thin:easycash/oracle@oracle:1521/validus"); Connection conn = ods.getConnection(); // Create Oracle DatabaseMetaData object DatabaseMetaData meta = conn.getMetaData(); // gets driver info: System.out.println("JDBC driver version is " + meta.getDriverVersion()); } } Could anyone help finish my work? Thanks, Sopolin

    Read the article

  • Timeout in LINQ to SQL inserting millions of records

    - by Bas
    I'm inserting approximently 3 million records in a database using this solution. Eventually when the application has been inserting records for a while (my last run lasted around 4 hours), it gives a timeout with the following SqlException: "SqlExcepetion: Timeout expired. The timeoutperiod elapsed prior to completion of the operation or the server is not responding." What's the best way to handle this exception? Is there a way to prevent this from happening or should I catch the exception? Thanks in advance!

    Read the article

  • Weblogic Error - Method not supported : Statement.cancel

    - by manetic
    I am running an application on Weblogic 9.2 MP3, currently having problem with connection pool. ERROR - UserBean retrieving user record. weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyApp Data Source to allocate to applications, please increase the size of the pool and retry.. I also kept getting below error message, saying "Method not supported : Statement.cancel()" which I think it is the cause to the error above. <Error> <JDBC> <BEA-001131> <Received an exception when closing a cached statement for the pool "MyApp Data Source": java.sql.SQLException: Method not supported : Statement.cancel()..> I went through the app source code, this method didn't seem to be used by the app at all. Just though it might be something to do with weblogic itself. Anyone have any idea to fix this error?

    Read the article

  • Statement.RETURN_GENERATED_KEYS concept

    - by rits
    import java.sql.* ; import java.util.* ; import java.io.* ; class DataBaseFactory{ public static Connection getConnection(){ ... ... ... ... } } class Demo{ public static void main(String []args) throws SQLException{ Connection con = DataBaseFactory.getConnection() ; //This is throwing exception //PreparedStatement ps = con.prepareStatement("insert into user values(?,?)", Statement.RETURN_GENERATED_KEYS) ; //But this is working fine PreparedStatement ps = con.prepareStatement("insert into user values(?,?)") ; } } thnx in advance to all the java people here....

    Read the article

  • Calling Stored Procedure from VB.net timeout error

    - by Jim
    When calling a stored procedure from vb.net is there a default SQL timeout time if no timeout is specified in the connection string? I am unsure if there is a CommandTimeout specified in the connection string but am going through all the possibilites. Example if no results after 30 seconds (or more) throw: `System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.` SQL Profiler says that the script runs and ends in 30 seconds when the program timesout.. Tthe script runs without error in about 1 minute 45 seconds by itself in SQL server.

    Read the article

  • Method with throws Exception: Where is it actually handled?

    - by Esq
    Here is an example code, I am throwing an exception here, it works perfectly fine without the try/catch block of code for some reason. Do I have to handle this inside this method "EntryDelete" or Do I have to handle this where the method is called from? If so can I see an example, what do I have to import in there? What is the acceptable syntax or method to do this? public boolean EntryDelete(int entryId) throws SQLException{ this.open(); kDatabase.delete(kENTRY_TABLE, kENTRY_ENTRY_ID + "=" + entryId, null); this.close(); return true; } Thanks

    Read the article

  • GetdataBy date doesn't work Why?

    - by vp789
    I am trying to pull the data by date in vb.net. It is not throwing the error nor giving any result. Whereas It shows the results in table adapter configuration wizard when I try through query builder. I am using date time picker in the form. But I have formatted the date in the database as date.I am puzzled. Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click Try Dim dt As Date = CDate(tspTextDate.Text) Me.Bank_transactionsTableAdapter.GetDataByDate(dt) 'Catch ex As Exception Catch ex As FormatException MessageBox.Show("date is wrong", "Entry Error") Catch ex As SqlException MessageBox.Show("SQL Server error#" & ex.Number _ & ":" & ex.Message, ex.GetType.ToString) End Try End Sub rows of data BT102 4/5/2010 BKS 200.00 1200.00 1400.00 BT103 4/5/2010 BKS 200.00 1400.00 1600.00 BT105 4/6/2010 BKS 200.00 1800.00 1800.00

    Read the article

  • MySQL Simple query gives "Query was empty". Transaction help needed I think.

    - by user129609
    Hi, I'm trying to do a simple transaction in MySQL delimiter go start transaction; BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION, SQLWARNING, NOT FOUND ROLLBACK; INSERT INTO jext_categories (Name) VALUES ('asdfas'); INSERT INTO jext_categories (Name) VALUES ('asdfas2'); END; commit; SELECT * FROM jext_categories; go delimiter ; but I keep getting an error saying query was empty. Could someone please tell me what I am doing wrong, and also, what is the proper format for doing a transaction in MySQL? Thanks!

    Read the article

  • Multivalue Mysql Inserts using HibernateTemplate

    - by Langali
    I am using Spring HibernateTemplate and need to insert hundreds of records into a mysql database every second. Not sure what is the most performant way of doing it, but I am trying to see how the multi value mysql inserts do using hibernate. String query = "insert into user(age, name, birth_date) values(24, 'Joe', '2010-05-19 14:33:14'), (25, 'Joe1', '2010-05-19 14:33:14')" getHibernateTemplate().execute(new HibernateCallback(){ public Object doInHibernate(Session session) throws HibernateException, SQLException { return session.createSQLQuery(query).executeUpdate(); } }); But I get this error: 'could not execute native bulk manipulation query.' Please check your query ..... Any idea of I can use a multi value mysql insert using Hibernate? or is my query incorrect? Any other ways that I can improve the performance? I did try the saveOrUpdateAll() method, and that wasn't good enough!

    Read the article

  • converting result set to list

    - by akshay
    how can i conver result set to list? i am using following code but its not working properly private List<User> convertToList(ResultSet rs) { List<User> userList = new ArrayList(); User user = new User(); try { while (rs.next()) { user.setId(rs.getInt("id")); user.setUsername(rs.getString("username")); user.setFname(rs.getString("fname")); user.setLname(rs.getString("lname")); user.setUsertype(rs.getInt("usertype")); user.setPasswd(rs.getString("passwd")); user.setEmail(rs.getString("email")); userList.add(user); } } catch (SQLException ex) { Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex); } finally { closeConnection(); } return userList; }

    Read the article

  • Spring & Hibernate SessionFactory - recovery from a down server

    - by MJB
    So pre spring, we used version of HibernateUtil that cached the SessionFactory instance if a successful raw JDBC connection was made, and threw SQLException otherwise. This allowed us to recover from initial setup of the SessionFactory being "bad" due to authentication or server connection issues. We moved to Spring and wired things in a more or less classic way with the LocalSessionFactoryBean, the C3P0 datasource, and various dao classes which have the SessionFactory injected. Now, if the SQL server appears to not be up when the web app runs, the web app never recovers. All access to the dao methods blow up because a null sessionfactory gets injected. (once the sessionfactory is made properly, the connection pool mostly handles the up/down status of the sql server fine, so recovery is possible) Now, the dao methods are wired by default to be singletons, and we could change them to prototype. I don't think that will fix the matter though - I believe the LocalSessionFactoryBean is now "stuck" and caches the null reference (I haven't tested this yet, though, I'll shamefully admit). This has to be an issue that concerns people.

    Read the article

  • Prepared statement initialized tiwice and closed once

    - by sonam
    Hi, I want to know that if a PreparedStatement object is initialized twice the way shown in code snippet below and closed only once in finally block, will it fail to close? I am not getting any error in this code but will it be a better idea to use 2 different preparedStatements instead of one. I think it fails to close the preparedStatement at #1. Connection conn = null; PreparedStatement ps = null; try { conn = getConnection(); ps = conn.prepareStatement(QueryUtil.UPDATE_POLICY_DETAILS); // #1 ps.setInt(1, iCancellationPolicyId); ps.executeUpdate(); //some code here ps = conn.prepareStatement(QueryUtil.UPDATE_POLICY_CHARGES); // #2 ps.setInt(1, iCancellationPolicyId); ps.executeUpdate(); //some code here } catch (SQLException sqlExp) { sqlExp.printStackTrace(); LOG.fatal(sqlExp); } finally { conn.close(); ps.close(); }

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >