Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartGWT and Database

    What is the best method to integrating my SmartGWT with a Database? Is there a good tutorial or project out there that shows exactly how SmartGWT, SmartClient, and a Database can all be integrated. I'm having a hard time finding a good example that would accomplish that. All the examples are incomplete or have bugs that I can't figured out how to fix.

    I'm trying to find out how I can edit a grid or a table and use a simple Database update, delete and insert functionalities.

    Thank you for you help!

    #2
    The easiest option would be to use SmartGWT Pro / EE and you can build an end to end CRUD page with only 10 - 20 lines of client side code and no additional server side code.

    Have a look at the Basic Connector sample and the associated code.

    Sanjiv has also posted a good overview of other features supported by SmartGWT EE.

    If you want to use SmartGWT LGPL instead, you'll have to write all the server side code to support the various CRUD operations, and on the client side follow the Rest DataSource sample. I'm not sure what "incomplete" or buggy examples you are referring to, but just follow this sample and write your own server side functionality to support the Rest operations.

    If you do come up with a more complete HowTo or Tutorial, please do share it with others.
    Last edited by smartgwt.dev; 6 Jul 2009, 11:01.

    Comment


      #3
      I get the fact you can get this working by looking at the examples posted on those pages but what I was looking for was an example where I can connect to my SQL server database and perform the CRUD functionalities.

      Comment


        #4
        Again, have a look at the source of the Basic Connector sample by clicking the "View Source" button. Select the tab that reads "server.properties". You'll notice that the HSQL database connection information is being used by this sample but if you scroll down a bit, you can see what it needs to be changed to in order to connect to SQL Server.

        I'm posting it here for your convenience.

        Code:
        # # SQLServer  
        # #----------  
        sql.SQLServer.database.type: sqlserver  
        sql.SQLServer.interface.type: driverManager  
           
        sql.SQLServer.driver: com.microsoft.jdbc.sqlserver.SQLServerDriver  
        sql.SQLServer.driver.url: jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=Northwind;User=sa;Password=
        Last edited by smartgwt.dev; 6 Jul 2009, 11:02.

        Comment


          #5
          Thanks.....this was very helpfull. I used the Readme file to set it up and upload the project.

          I have it working properly with the default database but I'm having a hard time finding the server.properities file in the project after I have it imported into Eclipse. I can find the file in the smartgwtee-1.2 download that I have and I tried to make the change there but it keeps poping up the default connection.

          Comment


            #6
            The server.properties file is present under the "src" directory of each sample. This file gets copied over to the WEB-INF/classes output directory when the project is built either from Eclipse, or the provided ant build file.

            Comment


              #7
              I was able to see the file in my directory but on my Project Explorer the folder "Classes" under WEB-INF didn't show up that was the reason I couldn't find it.

              After a few research all I had to do was view it in the Navigator mode and I can see WEB-INF/classes folder.

              Now I can go ahead and test to see if I can make it connect with my sql server database.

              Thanks again.

              Comment


                #8
                smartgwt.dev,

                I made the changes just like you said in the "server.properties" file but It is still defaulting to the default DB and showing the showcase page and when I try to click on the "Basic Connector" option it gives me an error about not having a sql-driver. Do I need to install a driver?

                thanks.

                Comment


                  #9
                  I'm a little confused. Which sample are you running?

                  You should be creating your own project, based on one of the simpler samples like ds-hibernate (other than the showcase because its too large). In your project then modify the server.properties pointing to your SQL Server database along with the appropriate code. For example the code that you see in the "View Source" of the "Basic Connector" sample.

                  And yes, you need to make sure the appropriate JDBC driver jar is included in your projects classpath. SmartGWT EE does not ship with any jdbc drivers other than for HSQL, which is used by the samples.

                  Comment


                    #10
                    Hi,
                    I'm trying to use the a MySql db with your in-built-ds smartgwtee example and its doing the query ok but all I get is an exception saying the table doesn't exist, i.e. its not creating the db schema (or populating the tables) when starting up.

                    Since it was doing this with the HSQLDB I thought it would do it with the MySQL db as well, have I missed something ?

                    Also localhost:8080/builtinds/tools returns page not found from jetty ... I see it configured in the server.porperties but I don't see any servlet mapping for it in the web.xml of the example.

                    I'm using the gwt hosted mode server to test on ...

                    Thanks for your help
                    Mike.

                    Comment


                      #11
                      Originally posted by mike_mac
                      Hi,

                      Since it was doing this with the HSQLDB I thought it would do it with the MySQL db as well, have I missed something ?
                      The provided sample does not automatically create the tables or populate them. It uses a file based HSQL DB that has the required tables and data. See the run-dbm script under the samples/db directory to launch a SQL client to view the database contents. Read the readme.txt file for connection details.

                      Comment


                        #12
                        Originally posted by smartgwt.dev
                        The provided sample does not automatically create the tables or populate them. It uses a file based HSQL DB that has the required tables and data. See the run-dbm script under the samples/db directory to launch a SQL client to view the database contents. Read the readme.txt file for connection details.
                        Thanks for the quick response,

                        I thought the server supported the auto creation of db tables based on ds.xml files was supported, was I miss informed ? or is it only with HSQL ?

                        Oh, Any thoughts on why my admin console doesn't work ? :-)

                        Comment


                          #13
                          Table generation works with all supported DBs and is done via the Admin Console.

                          The Admin Console is probably broken because of various files still missing from your deployment. Simplest thing is to deploy the Showcase which includes the tool.

                          Comment


                            #14
                            Originally posted by mike_mac
                            Oh, Any thoughts on why my admin console doesn't work ? :-)
                            How are you trying to launch the admin console?

                            Try inheriting this module :

                            <inherits name="com.smartgwtee.tools.Tools"/>

                            and then call

                            Code:
                            com.smartgwtee.tools.client.SCEE.openDataSourceConsole();

                            Comment

                            Working...
                            X