Announcement

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

    Database connection without using Spring , Hibernate

    Hi ,

    I want to connect to MYSQL database without using Spring/Hibernate , read about mySQL connector but not working for me.
    Also , wanted to know how to incorporate fields like which are fetched via some referential constraint (from another entity) like data from a table with few columns from another table using same approach.
    Also will i be able to add event handlers with seperate fields of the grid using this approach and how things can be modifed if i want to put some logic around update/fetch operations related to the grid?
    please help.

    #2
    Hi marwan12,

    Originally posted by marwan12 View Post
    I want to connect to MYSQL database without using Spring/Hibernate , read about mySQL connector but not working for me.
    See the Quick Start Guide for this. Generally speaking, you'll need a Pro/Power/EE (or Enterprise Eval) version and make your DB known in the server.properties file. You'll also need a JDBC driver for your database.
    Also make sure to read the Quick Start Guide cover to cover and the FAQ here in the forum.

    Originally posted by marwan12 View Post
    Also , wanted to know how to incorporate fields like which are fetched via some referential constraint (from another entity) like data from a table with few columns from another table using same approach.
    These fields use the includeFrom-concept.


    Originally posted by marwan12 View Post
    Also will i be able to add event handlers with seperate fields of the grid using this approach and how things can be modifed if i want to put some logic around update/fetch operations related to the grid?
    please help.
    See chapter "Direct Method Invocation" in the QSG for this. You really should start with this one.

    Best regards
    Blama

    Comment


      #3
      hardTried doing the same , but getting this error: DataSource '' failed to load due to an exception on the server:
      com.isomorphic.sql.SQLDataSource
      See the server-side log for additional details.
      at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:289)
      at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:107)

      PFA the grid view file and server properties file
      Code for properties file:
      # The webRoot directory:
      # the directory that the servlet engine regards as the place where applications
      # that use the servlet engine should be installed. Generally, it is safe to leave
      # this at the default setting of __AUTODETECT__. When the SmartClient server is
      # started, it logs a message to stdout telling you the autodetected path to your
      # webRoot. If this path is not your actual webRoot, then you'll want to override
      # this config parameter here.
      #
      # Valid values:
      #
      # 1. Absolute path to the webRoot directory
      #
      # 2. Special token: __AUTODETECT__
      # When this token is used, SmartClient attempts to auto-detect the webRoot using
      # standard servlet APIs. This may or may not work - depending on your
      # container type and deployment type. For example, WAR/EAR deployments
      # on some containers never make it to disk, and so the container refuses
      # to provide the webRoot path.
      #
      # If SmartClient cannnot detect the webRoot, it sets the webRoot to
      # __USE_CONTAINER__ (see below).
      #
      # 3. Special token: __USE_CONTAINER__
      # When this token is used, SmartClient uses standard servet APIs for accessing
      # filesystem resources. This is slower than direct file access and, since
      # the servlet APIs provide no mechanism for writing to disk, means that some
      # development tools like the FileAssembler will not work.
      #
      webRoot: __AUTODETECT__

      # Set this to the GWT module name.
      gwtModuleName:

      # if you've moved the isomorphic directory from its default location in webRoot,
      # set the root-relative path to it here
      #
      # For example, if in your deployment the 'isomorphic' dir is in /foo/bar, then set
      # then you'll need to set this to foo/bar/isomorphic
      isomorphicPathRootRelative: $gwtModuleName/sc



      # -------------- PICK DATABASE TO USE --------------------
      #
      # The SmartClient SDK ships with examples that use a database as the persistence
      # layer. By default, the SDK uses a built-in version of HSQLDB, but you can
      # specify a different database to use here.

      # which database do you want to use? HSQLDB is enabled by default.
      #sql.defaultDatabase: HSQLDB

      # If you want to use Mysql instead, uncomment the following line
      # and comment all other sql.defaultDatabase definitions
      #sql.defaultDatabase: Mysql
      sql.defaultDatabase: hsqldb

      # If you want to use Oracle instead, uncomment the following line
      # and comment all other sql.defaultDatabase definitions
      #sql.defaultDatabase: Oracle

      # If you want to use Postgres instead, uncomment the following line
      # and comment all other sql.defaultDatabase definitions
      #sql.defaultDatabase: PostgreSQL

      # If you want to use DB2 instead, uncomment the following line
      # and comment all other sql.defaultDatabase definitions
      #sql.defaultDatabase: DB2

      # -------------- SETTINGS FOR HSQLDB --------------------

      sql.HSQLDB.database.type: hsqldb
      sql.HSQLDB.interface.type: driverManager

      sql.HSQLDB.driver: org.hsqldb.jdbcDriver
      sql.HSQLDB.driver.url: jdbc:hsqldb:hsql://localhost/isomorphic

      # -------------- SETTINGS FOR MYSQL --------------------

      # These are the settings for use with the Mysql database. If you have
      # just done a fresh install of MySQL on the same machine where you are
      # running your servlet engine, the values provided below will probably
      # just work on most platforms.

      # Configuration for Mysql Connector/J
      sql.Mysql.database.type: mysql
      sql.Mysql.database.ansiMode: false
      sql.Mysql.interface.type: dataSource
      sql.Mysql.driver: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
      # name of the database to use
      sql.Mysql.driver.databaseName: pbs_dev
      # hostname and port where the database server is installed
      sql.Mysql.driver.serverName: localhost
      sql.Mysql.driver.portNumber: 3306
      # username and password that can create and modify tables in that database
      # this user must have the following privileges for the system to function
      # properly: create/alter/drop table; insert/update/replace/delete rows.
      sql.Mysql.driver.user: root
      sql.Mysql.driver.password:root



      # -------------- LOADING APP AND DATASOURCE DEFINITIONS --------------------

      # Where the system looks for DataSource definition files ([dataSourceId].ds.xml or
      # [dataSourceID].ds.js). It's useful to put all your DataSources in one
      # directory since DataSources are frequently shared between applications.
      # "project.datasources" is also where the DataSource Importer tool looks
      # for available DataSources.
      project.datasources: $webRoot/ds
      project.ui: $webRoot/shared/ui
      project.apps: $webRoot/shared/app

      # -------------- Other settings --------------------
      # The setting RPCManager.enabledBuiltinMethods enables or disables the BuiltInRPCs - RPC calls
      # that are built into the SmartClient Server. The setting below reflects the framework default
      # of enabling only those RPCs that are typically needed in an application.
      #
      # See the JavaDoc for com.isomorphic.rpc.BuiltinRPC and com.isomorphic.tools.BuiltinRPC for all
      # available builtinRPCs and their behavior.
      #
      # Note that many of the BuiltinRPCs are designed for use by tools such as Visual Builder, and
      # provide services such as direct access to the file system (for load and save of screens) that
      # would be unsafe to expose to untrusted users.
      #
      #RPCManager.enabledBuiltinMethods: getPdfObject, xmlToJS, uploadProgressCheck, exportClientData, downloadClientExport, setAttributes

      # Note: modulesDir is only used with the loadISC and loadModules JSP tags; if
      # you intend to use those tags, do not change this setting
      modulesDir: modules/





      code for grid view file:


      public class TestView {

      static VLayout mainPanel;

      private static ViewListGrid test;



      public static VLayout getInstnce() {
      final ViewState viewState = new ViewState(GridViewConstants.TEST_PAGE);
      mainPanel = new VLayout();
      mainPanel.setWidth("100%");
      mainPanel.setStyleName("bodyContainer");
      viewState.getBus().addHandler(GridViewReceiveEvent.TYPE, new GridViewReceiveEventHandler() {

      @Override
      public void onEvent(GridViewReceiveEvent event) {
      final DataSource testDS = DataSource.get("Vendor");
      final ListGrid vendorGrid = createGrid(testDS , viewState);
      mainPanel.addChild(vendorGrid);
      }
      });
      return mainPanel;
      }



      private static ListGrid createGrid(final DataSource testDS , final ViewState viewstate) {
      final Label labelAnswer = new Label("Your answer here...");
      labelAnswer.setTop(50);
      labelAnswer.setWidth(300);

      test = new ViewListGrid(GridViewConstants.TEST_GRID,
      GridViewConstants.TEST_GRID_EXPORT_FILE, viewstate, true) {


      @Override
      protected Canvas getExpansionComponent(final ListGridRecord record) {

      }


      @Override
      public void insertNewRow() {
      // TODO Auto-generated method stub

      }
      };

      test.setDataSource(vendorDS);
      test.setWidth100();
      test.setStyleName("vendorGrid listGrid ");
      test.setShowFilterEditor(true);
      test.setFilterOnKeypress(true);
      ListGridField abbrField = new ListGridField(ClientConstants.TEST_VIEW_FIELD_ABBR,
      "testabbr");
      abbrField.setWidth("10%");
      abbrField.setCanEdit(false);
      ListGridField nameField = new ListGridField(ClientConstants.TEST_VIEW_FIELD_NAME,
      "testname");
      nameField.setWidth("30%");
      nameField.setCanEdit(false);

      test.setCanEdit(true);
      test.setHeight("90%");
      test.setAutoFetchData(true);

      test.setAutoSaveEdits(true);
      test.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
      return test;
      }



      }


      Last edited by marwan12; 2 Aug 2017, 02:35.

      Comment


        #4
        The error message says to see the server-side logs. So you should do that.

        Note also the FAQ (in these forums) has troubleshooting steps for failing to load a DataSource.

        Comment


          #5
          In hibernate we have options to create paramterized constructors which we can use to populate the entity as per the requirement , do we have the same option in case of direct connection to database without hibernate support?
          Also like we can mention some fields as transient in case we need to make them available on UI but not for persistence , can we achieve the same without hibernate?

          Comment


            #6
            See the QuickStart Guide. For the first question, see the Server Framework chapter, and consider DMI and also Custom DataSources. For the second, note that you can provide fields that to a DataBoundComponent that are not actually persisted fields - see the Data Binding chapter.

            Comment

            Working...
            X