15 Replies Latest reply on Dec 20, 2011 4:41 AM by Dan Bracuk

    Transform Query inside cfscript to not access java objects

    lovewebdev Level 1

      When I uploaded my page, now my webhost is saying my queries accessing java objects isn't allowed. I'm having trouble figuring out how to change these queries so they don't use a java object.

       

      Here is one of my queries. All my other queries are in the same format:

       

       

      objFactory1 = CreateObject(
      "java",
      "coldfusion.server.ServiceFactory"
      );
      
      // Get the Data Source service from the service factory.
      objDataService1 = objFactory1.DataSourceService;
      
      // The data service object has access to all data sources
      // running on the server. Let's get a connection to our
      // datasource before running the query.
      objDataSource1 = objDataService1.GetDataSource(
      "myapp"
      );
      
      // Open the connection. Here, we have the option to pass
      // in a username and password. Since I am on the dev
      // server, no need to do so.
      objConnection1 = objDataSource1.GetConnection(
      // USERNAME, PASSWORD if needed //
      dsnlogin,dsnpwd);
      
      // Prepare the SQL statement that you want to run. Much
      // harder than the CFQuery tag, but not impossible.
      getevents = objConnection1.PrepareStatement(
      "SELECT " &
      "dtstamp, " &
      "eventname " &
      "FROM " &
      "events " &
      "WHERE MONTH(DATE(dtstamp)) = " & CurMonth & " AND DAYOFMONTH(DATE(dtstamp)) = " & i
      );
      
      // of object that we are all used to working with.
      getevents = CreateObject(
      "java",
      "coldfusion.sql.QueryTable"
      ).Init( getevents.ExecuteQuery() );
      
      // Close the connection.
      objConnection1.Close();
      
      

       

       

      I'm returning columns like this : getevents.eventname[intRow]