• Unable to save data using xe:jdbcRowSet to MySQL

    By Naveen Maurya 1 decade ago

     

    I am trying to save data from my XPage to MySQL database. I have established a connection and it works (which is demonstrated by the fact that my dynamic view panel is able to fetch data in MySQL tables). But I am unable to submit my data to MySQL. I am following the example database ofXPagesJDBC.nsf in extension library.

    MySQL connection file mysqlconn.jdbc:

    
        com.mysql.jdbc.Driver
        jdbc:mysql://***.***.***.***:3306/project_management
        adminuser
        ******
    

    In my XPage I create a data source with xe:jdbcRowSet

    
        
        
    

    Then in my xp:panel I use the data source to save the object. I have two fields of name and description mapped to respective columns in tables in MySQL database.

     

    
        
            
                
            
        
        
            
                Name
                
                    
                
            
            
                Description
                
                    
                    
                
            
            
                
                    
                        
                            
                                
                                    
                                    
                                    
                                
                            
                        
                    
                
            
        
    

    When I try to click on Save button data is not saved and no error is shown. But if I change the Button type to Submit () it gives me error:

    Error saving data source jdbcrsProjectMgmt
    javax.sql.rowset.spi.SyncProviderException: Can't call commit when autocommit=true
    Can't call commit when autocommit=true

    But this time strangely the data gets saved. I can't find this autocommit property and don't know where to set it. How can I solve this? Is this issue with XPages or MySQL?

    • Check your data types

      By Janey Cringean 1 decade ago

      We've been doing this for over a year now and have production systems using it very successfully. It works fine when you're careful. However this error will show if your data types are not correct. An example is setting a string field with the value of @Unique. You need to use row.col=session.evaluate("@Unique").elementAt(0) because @Unique returns an array. Similarly setting integer fields with text values will do the same. If you get the field types correct it works like a dream.