1 2 Previous Next 49 Replies Latest reply on Jun 25, 2007 3:16 AM by ik1hsr

    Problem with return a ColdFusion query object from a Java class

    ik1hsr
      Hi!
      I need to return a ColdFusion query object from a Java class using a JDBC result set ( java.sql.ResultSet);

      I have tried to pass my JDBC result set in to the constructor of the coldfusion.sql.QueryTable class with this code:


      ColdFusion code

      <cfset pra = createObject("java","QueryUtil").init()>
      <cfset newQuery = CreateObject("java", "coldfusion.sql.QueryTable")>
      <cfset newQuery.init( pra.getColdFusionQuery () ) >

      My java class execute a query to db and return QueryTable

      Java code (QueryUtil.java)

      import coldfusion.sql.QueryTable; // (CFusion.jar for class QueryTable)
      import com.allaire.cfx //(cfx.jar for class Query used from QueryTable)
      public class QueryUtil
      {
      public static coldfusion.sql.QueryTable getColdFusionQuery(java.sql.ResultSet rs)
      {
      return new coldfusion.sql.QueryTable(rs);
      }
      }

      but when i run cfm page and coldfusion server tries to execute : "<cfset pra = createObject("java","QueryUtil").init()>" this error appears:

      Object Instantiation Exception.
      An exception occurred when instantiating a java object. The cause of this exception was that: coldfusion/sql/QueryTable.

      If i try to execute QueryUtil.java with Eclipse all it works.

      Also I have tried to return java.sql.ResultSet directly to coldfusion.sql.QueryTable.init () with failure.

      Do you know some other solution?
        • 1. Re: Problem with return a ColdFusion query object from a Java class
          insuractive Level 3
          You can go down the serializable route and convert your java recordset into something that you can load into CF (e.g. WDDX, XML, JSON). That way you get a plain text result from java that you can load into CF. Personally I'd go with WDDX. I'm sure there are some Java WDDX functions and you can use <cfwddx> to convert it to a CF query (pretty fast).
          • 2. Problem with return a ColdFusion query object from a Java class
            Stressed_Simon Level 1
            Why are you trying to return a ColdFusion Query? Usually you would return a native Java datatype like a Vector of value objects. Otherwise your going to have to construct a query in ColdFusion which is extra looping.
            • 3. Re: Problem with return a ColdFusion query object from a Java class
              cf_dev2 Level 1
              ik1hsr,

              I think there are some other problems with the code, but to start with:

              [ColdFusion code]

              <cfset newQuery = CreateObject("java", "coldfusion.sql.QueryTable")>
              <cfset newQuery.init( pra.getColdFusionQuery () ) >

              [/ColdFusion code]

              The getColdFusionQuery() method already returns a "coldfusion.sql.QueryTable" object. So technically you don't have to create another one.

              [ColdFusion code]

              <cfset newQuery.init( pra.getColdFusionQuery () ) >

              [[/ColdFusion code]

              The getColdFusionQuery() method expects a parameter of type java.sql.ResultSet. But you're calling the method without passing in any parameters.

              You might want to review the cfx classes. Specifically the addQuery() method.
              • 4. Re: Problem with return a ColdFusion query object from a Java class
                ik1hsr Level 1
                I have modified my code:

                [Coldfusion code]
                ...
                rs = st.executeQuery("SELECT * FROM Table");
                ourQuery = createObject("java","QueryUtil").getColdFusionQuery(rs);
                ...
                [/ColdFusion code]

                java class
                --------------------------------------------------------
                import coldfusion.sql.QueryTable;
                public class QueryUtil
                {
                public static QueryTable getColdFusionQuery(java.sql.ResultSet rs) throws java.sql.SQLException
                {
                return new QueryTable(rs);
                }
                }
                --------------------------------------------------

                But when i run it occurs the same error:

                --------------------------------------------------------------------
                An exception occurred when instantiating a java object. The cause of this exception was that: coldfusion/sql/QueryTable.
                -----------------------------------------------------------------------

                Do you know why??

                • 5. Re: Problem with return a ColdFusion query object from a Java class
                  cf_dev2 Level 1
                  ik1hsr,

                  Can you explain your overall goal? I ask because typically you don't create a java resultset in ColdFusion code. You simply use cfquery.

                  <cfquery name="YourQuery" datasource="YourDatasource">
                  SELECT * FROM Table
                  </cfquery>

                  This creates a query object named "YourQuery" that you can use in your ColdFusion code. So there is no need to create a java resulset.

                  Are you trying to do something different?
                  • 6. Re: Problem with return a ColdFusion query object from a Java class
                    ik1hsr Level 1
                    Yes, i need to use this java.class...
                    ..now i'm trying to serialize the ResultSet and use it in CF with WDDX....
                    • 7. Re: Problem with return a ColdFusion query object from a Java class
                      ik1hsr Level 1
                      this is the reason for which i can't use CFQUERY

                      -- I have cfc component that implements my Business logic (some sql query)
                      -- I need to create a java class to replace this cfc.



                      • 8. Re: Problem with return a ColdFusion query object from a Java class
                        insuractive Level 3
                        I don't know if it helps, but I found this page with the properties / methods for QueryTable:

                        http://www.zrinity.com/developers/mx/undocumentation/query.cfm

                        Do you still get the same error if you try an instantiate the object using the default constructor:

                        return new QueryTable();

                        If so, I would theorize that perhaps the CF java objects are protected somehow. Though it doesn't seem so from the link I just mentioned.
                        • 9. Re: Problem with return a ColdFusion query object from a Java class
                          ik1hsr Level 1
                          thanks for the reply,but i search in google for a week.....
                          • 10. Re: Problem with return a ColdFusion query object from a Java class
                            insuractive Level 3
                            Have you tried recreating the entirety of the java code in CF using createObject()?

                            rs = st.executeQuery("SELECT * FROM Table");
                            objQT = createObject("java","coldfusion.sql.QueryTable");

                            <!--- Try init() or populate() --->
                            objQT.init(rs);
                            <!--- or --->
                            objQT.init();
                            objQT.populate(rs);

                            Then do a dump of objQT and see what you get?
                            • 11. Re: Problem with return a ColdFusion query object from a Java class
                              cf_dev2 Level 1
                              ik1hsr,

                              I haven't tried it, but functionally insuractive's suggestion sounds right.

                              >> this is the reason for which i can't use CFQUERY
                              >>-- I have cfc component that implements my Business logic (some sql query)
                              >> -- I need to create a java class to replace this cfc.

                              Why switch from cfc's to a java class? Is it a business requirement or some other reason? I ask because: at a basic level cfqueries _may_ be faster than creating your own resultsets. ColdFusion can utilize connection pooling. If you create your own resultsets, I don't think you have that advantage, unless you implement it yourself (or find a way to use CF's pooling). So I think you still have the overhead of opening a connection for each query, which can slow things down.


                              • 12. Re: Problem with return a ColdFusion query object from a Java class
                                ik1hsr Level 1
                                it's a business requirement;

                                Java class implements some method such as search(...),update(...),delete(...),insert(....),new(....)

                                In coldfusion i use this java class to replace a cfc that implements the same operation.

                                Someone knows a valid method to pass a ResultSet from JAVA to ColdFusion Query?

                                I have tried to use the code of this site:

                                http://www.petefreitag.com/item/73.cfm

                                But the problem is the same one of the previous post

                                --------------------------------------------------------------------
                                An exception occurred when instantiating a java object. The cause of this exception was that: coldfusion/sql/QueryTable.
                                -----------------------------------------------------------------------
                                • 13. Re: Problem with return a ColdFusion query object from a Java class
                                  ik1hsr Level 1
                                  stack trace

                                  java.lang.NoClassDefFoundError: coldfusion/sql/QueryTable at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:1655) at java.lang.Class.privateGetPublicMethods(Class.java:1778) at java.lang.Class.getMethods(Class.java:832) at coldfusion.runtime.java.ObjectHandler.Initialize(ObjectHandler.java:40)

                                  ...
                                  ..
                                  ..
                                  • 14. Re: Problem with return a ColdFusion query object from a Java class
                                    cf_dev2 Level 1
                                    import java.sql.SQLException;
                                    import coldfusion.sql.QueryTable;

                                    public class QueryUtil {

                                    public static coldfusion.sql.QueryTable getColdFusionQuery(java.sql.ResultSet rs)
                                    throws SQLException {

                                    return new coldfusion.sql.QueryTable(rs);
                                    }
                                    }

                                    ... (create resultset code) ...
                                    <cfset newQuery = createObject("java","QueryUtil").getColdFusionQuery(rs) />
                                    <!--- must close resulset when finished --->
                                    <cfset rs.close()>
                                    <cfdump var="#newQuery#">
                                    • 15. Re: Problem with return a ColdFusion query object from a Java class
                                      ik1hsr Level 1
                                      ok

                                      i print all my code

                                      pratica.java execute a query to db and return a querytable


                                      java class
                                      ------------------------------------------------------------------------------------------ -----------------
                                      import java.util.*;
                                      import java.sql.*;
                                      import coldfusion.sql.*;

                                      public class Pratica {
                                      private HashMap my;
                                      private String URI,LOGIN,PWD,DRIVER;
                                      private Connection conn=null;



                                      /////////////////////////////////////////////////
                                      //funzione init
                                      //
                                      //riceve due strutture converite in hashmap
                                      // globals
                                      // dbprop
                                      ////////////////////////////////////////////////

                                      public Pratica(HashMap globals,HashMap dbprop) {

                                      my = new HashMap();
                                      my.put("GLOBALS",globals);
                                      my.put("DBPROP",dbprop);
                                      URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
                                      LOGIN = "usr_dev";
                                      PWD = "developer";
                                      DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
                                      try{
                                      // Carico il driver JDBC per la connessione con il database MySQL
                                      Class.forName(DRIVER);
                                      /* Connessione alla base di dati */
                                      conn=DriverManager.getConnection(URI,LOGIN,PWD);
                                      if(conn!=null) System.out.println("Connection Successful!");
                                      } catch (ClassNotFoundException e) {
                                      // Could not find the database driver
                                      System.out.print("\ndriver non trovato "+e.getMessage());
                                      System.out.flush();
                                      }
                                      catch (SQLException e) {
                                      // Could not connect to the database
                                      System.out.print("\nConnessione fallita "+e.getMessage());
                                      System.out.flush();
                                      }
                                      }


                                      //////////////////////////////////////////////////
                                      //funzione search
                                      //
                                      //riceve un hash map con i filtri di ricerca
                                      /////////////////////////////////////////////////

                                      public QueryTable search(/*HashMap arg*/) {
                                      ResultSet rs=null;
                                      Statement stmt=null;
                                      QueryTable ret=null;
                                      String query="SELECT * FROM TAN100pratiche";
                                      try{
                                      stmt = conn.createStatement();// Creo lo Statement per l'esecuzione della query
                                      rs=stmt.executeQuery(query);
                                      // while (rs.next()) {
                                      // System.out.println(rs.getString("descrizione"));
                                      // }
                                      }
                                      catch (Exception e) {
                                      e.printStackTrace();
                                      }

                                      try {
                                      ret = Pratica.RsToQueryTable(rs);
                                      } catch (SQLException e) {
                                      e.printStackTrace();
                                      }
                                      this.close();
                                      return(ret);
                                      // ret=this.RsToQuery(rs);

                                      // this.close(); //chiude le connessioni,recordset e statament


                                      }

                                      //////////////////////////////////////////////////
                                      //retstruct CF vede HashMap come struct
                                      //METODO DI TEST
                                      ///////////////////////////////////////////////////
                                      public HashMap retstruct(){
                                      return(my);
                                      }
                                      //////////////////////////////////////////////////
                                      //conversione resultset to querytable
                                      //
                                      //////////////////////////////////////////////////

                                      private static QueryTable RsToQueryTable(ResultSet rs) throws SQLException{
                                      return new QueryTable(rs);
                                      }

                                      /////////////////////////////////////////////
                                      //chiura resultset statament e connessione
                                      ////////////////////////////////////////////
                                      private void close(){
                                      try{
                                      conn.close();
                                      conn=null;
                                      }
                                      catch (Exception e) {
                                      e.printStackTrace();
                                      }

                                      }

                                      }
                                      ------------------------------------------------------------------------------------------ ----

                                      coldfusion code

                                      ------------------------------------------------------------------------------------------ --
                                      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                                      <html>
                                      <head>
                                      <title>Test JDBC CFML Using CFScript</title>
                                      </head>

                                      <body>
                                      <cftry>
                                      <cfset glb_map = createObject("java","java.util.HashMap")>
                                      <cfset dbprop_map = createObject("java","java.util.HashMap")>
                                      <cfset glb_map.init(glb)> <!---are passed from another page--->
                                      <cfset dbprop_map.init(glb["DBPROP"])>
                                      <cfset pra = createObject("java","Pratica").init(glb_map,dbprop_map)>
                                      <cfset ourQuery =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
                                      <cfcatch>
                                      <h2>Error - info below</h2>
                                      <cfdump var="#cfcatch#"><cfabort>
                                      </cfcatch>
                                      </cftry>
                                      <h2>Success - statement dumped below</h2>
                                      <cfdump var="#ourQuery#">
                                      </body>
                                      </html>
                                      ------------------------------------------------------------------------------------------ ---------

                                      error at line <cfset pra = createObject("java","Pratica").init(glb_map,dbprop_map)>

                                      --------------------------------------------------------------------
                                      An exception occurred when instantiating a java object. The cause of this exception was that: coldfusion/sql/QueryTable.
                                      -----------------------------------------------------------------------
                                      • 16. Re: Problem with return a ColdFusion query object from a Java class
                                        cf_dev2 Level 1
                                        What about the stack trace error?
                                        • 17. Re: Problem with return a ColdFusion query object from a Java class
                                          ik1hsr Level 1

                                          Message
                                          coldfusion/sql/QueryTable
                                          StackTrace
                                          java.lang.NoClassDefFoundError: coldfusion/sql/QueryTable at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:1655) at java.lang.Class.privateGetPublicMethods(Class.java:1778) at java.lang.Class.getMethods(Class.java:832) at coldfusion.runtime.java.ObjectHandler.Initialize(ObjectHandler.java:40) at coldfusion.runtime.java.ObjectHandler.<init>(ObjectHandler.java:26) at coldfusion.runtime.java.ReflectionCache$1.fetch(ReflectionCache.java:27) at coldfusion.util.WeakKeyCache.get(WeakKeyCache.java:40) at coldfusion.runtime.java.ReflectionCache.get(ReflectionCache.java:33) at coldfusion.runtime.java.JavaProxy.<init>(JavaProxy.java:27) at coldfusion.runtime.CFPage.createObject(CFPage.java:5783) at coldfusion.runtime.CFPage.CreateObject(CFPage.java:5677) at coldfusion.runtime.CFPage.CreateObject(CFPage.java:5642) at cftest_java_22ecfm1357198390.runPage(C:\CFusionMX7\wwwroot\gruppotesi\goldenring\airone\c ore\framework\util\test_java_2.cfm:14) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:225) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:51) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:2 8) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115) at coldfusion.CfmServlet.service(CfmServlet.java:107) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541) at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
                                          • 18. Re: Problem with return a ColdFusion query object from a Java class
                                            cf_dev2 Level 1
                                            I think you forgot to import the jdbc driver class. There are different versions, so check the package path may not be correct for your version.

                                            import java.util.*;
                                            import java.sql.*;
                                            import coldfusion.sql.*;
                                            import com.microsoft.sqlserver.jdbc.*; // <!---- import jdbc driver

                                            • 19. Re: Problem with return a ColdFusion query object from a Java class
                                              cf_dev2 Level 1
                                              Test the class in your java IDE first - before trying it with ColdFusion:

                                              import java.util.*;
                                              import java.sql.*;
                                              import coldfusion.sql.*;
                                              import com.microsoft.sqlserver.jdbc.*; // <!---- import jdbc driver

                                              public class Pratica {
                                              //.... declarations, other methods ... etcetera

                                              public static void main(String[] args) {
                                              //test java class
                                              Pratica p = new Pratica(new HashMap(), new HashMap());
                                              p.close();
                                              }
                                              }
                                              • 21. Re: Problem with return a ColdFusion query object from a Java class
                                                ik1hsr Level 1
                                                I have tried to import jdbc driver but occurs the same error.......

                                                in my java IDE it works......

                                                ????????????????????????????????????
                                                • 22. Re: Problem with return a ColdFusion query object from a Java class
                                                  cf_dev2 Level 1
                                                  import com.microsoft.sqlserver.jdbc.*;

                                                  Are the sql server jdbc jars in the CF classpath?
                                                  • 24. Re: Problem with return a ColdFusion query object from a Java class
                                                    cf_dev2 Level 1
                                                    Did you restart CF after replacing the .class file with the newer version? It may still be using the old class file.

                                                    If not, can you post the error, with the cf code line.
                                                    • 25. Re: Problem with return a ColdFusion query object from a Java class
                                                      ik1hsr Level 1
                                                      Yes.i had restar coldfusion...........

                                                      the error is the same of the previous post
                                                      • 26. Re: Problem with return a ColdFusion query object from a Java class
                                                        cf_dev2 Level 1
                                                        It worked fine for me, so either CF is using the wrong version of the class or you're using different code than I am.

                                                        Can you post the exact code you're using?
                                                        • 27. Re: Problem with return a ColdFusion query object from a Java class
                                                          cf_dev2 Level 1
                                                          On second thought, is the error still at this line or a different line?

                                                          error at line <cfset pra = createObject("java","Pratica").init(glb_map,dbprop_map)>
                                                          • 28. Re: Problem with return a ColdFusion query object from a Java class
                                                            ik1hsr Level 1
                                                            Can you give me your e-mail in private message so i'll send you my java code,my cf code, the screenshot about my system information and about stacktrace.
                                                            thanks in advance
                                                            • 30. Re: Problem with return a ColdFusion query object from a Java class
                                                              monkey_woo_too Level 1
                                                              Pete Freitag knows how to do it:

                                                              http://www.petefreitag.com/item/73.cfm

                                                              I wouldn't do it that way though as its all a bit undocumented...

                                                              I would return your java ResultSet object back to CF and populate a new query using QuerySetCell etc. etc.

                                                              You might be able to find someone elses utiltity function out there to do it for you.
                                                              • 31. Re: Problem with return a ColdFusion query object from a Java class
                                                                cf_dev2 Level 1
                                                                The only problems with the code are the two things I mentioned:
                                                                1) You must import the jdbc driver class at the top of the Pratica class
                                                                2) The sql server 2005 jdbc jar must be in the CF classpath **

                                                                ** The classpath is very long. I couldn't tell whether the 2005 driver jar is in the CF classpath or not. Do a search to be certain. I think the 2005 jar is named"sqljdbc.jar".

                                                                • 32. Re: Problem with return a ColdFusion query object from a Java class
                                                                  ik1hsr Level 1
                                                                  ok
                                                                  1)i had insert:

                                                                  import com.microsoft.sqlserver.jdbc.*;

                                                                  at the top of the java code

                                                                  2) i had insert sqljdcb.jar in CF classpath:

                                                                  CF administrator-->server settings--> Java and JVM-->ColdFusion Classpath:
                                                                  C:\CFusionMX7\wwwroot\WEB-INF\lib\cfx.jar,
                                                                  C:\CFusionMX7\lib\cfusion.jar,
                                                                  C:\Programmi\Driver_SqlServer\sqljdbc_1.1\ita\sqljdbc.jar

                                                                  3)restar CF

                                                                  but the same error occurs at the same line....

                                                                  The problem is when CF try to use QueryTable in Cfusion.jar.....
                                                                  • 33. Re: Problem with return a ColdFusion query object from a Java class
                                                                    ik1hsr Level 1
                                                                    For monkey woo too:

                                                                    Thanks for your help.......,
                                                                    ......but i know how to use the SEARCH button in google.....
                                                                    • 34. Re: Problem with return a ColdFusion query object from a Java class
                                                                      cf_dev2 Level 1
                                                                      1. Did you test the new code in your IDE do you get the "Connection Successful!" message? I tested it with the sql 2000 jar (2005 isn't installed on this machine).

                                                                      2. Did you place the new class in c:\cfusionmx7\wwwroot\web-inf\classes\ (or whereever you put your classes) before you restarted CF?
                                                                      • 36. Re: Problem with return a ColdFusion query object from a Java class
                                                                        cf_dev2 Level 1
                                                                        Something is not right. It works perfectly with 2000. I see no reason it should not work with 2005.

                                                                        1. Try this. Add a version number to the java class:

                                                                        import java.util.*;
                                                                        import java.sql.*;
                                                                        import coldfusion.sql.*;
                                                                        import com.microsoft.sqlserver.jdbc.SQLServerDriver;

                                                                        public class Pratica {
                                                                        private HashMap my;
                                                                        private String URI,DRIVER,LOGIN,PWD;
                                                                        private Connection conn=null;
                                                                        private String version = "0.1";

                                                                        public static void main(String[] args) {
                                                                        Pratica p = new Pratica(new HashMap(), new HashMap());
                                                                        System.out.println(p.getVersion());
                                                                        p.close();
                                                                        }

                                                                        public String getVersion() {
                                                                        return version;
                                                                        }

                                                                        /////////////////////////////////////////////////
                                                                        //funzione init
                                                                        //
                                                                        //riceve due strutture converite in hashmap
                                                                        // globals
                                                                        // dbprop
                                                                        ////////////////////////////////////////////////

                                                                        ... rest of java code

                                                                        2. Run the code in your IDE. It should print

                                                                        Connection Successful!
                                                                        0.1

                                                                        3. Place the new Pratica.class in c:\cfusionmx7\wwwroot\web-inf\classes\ and restart CF

                                                                        4. Run this CF code:

                                                                        <cftry>
                                                                        <cfset emptyMap = createObject("java", "java.util.HashMap").init()>
                                                                        <cfset pra = createObject("java","Pratica").init(emptyMap, emptyMap)>
                                                                        <cfoutput>Version: #pra.getVersion()#</cfoutput>
                                                                        <cfcatch>
                                                                        <h2>Error - info below</h2>
                                                                        <cfdump var="#cfcatch#"><cfabort>
                                                                        </cfcatch>
                                                                        </cftry>
                                                                        <h2>Success</h2>

                                                                        ----------------------------------------------
                                                                        If you don't see this message, CF is not using the correct class:

                                                                        Version: 0.1
                                                                        Success

                                                                        • 37. Re: Problem with return a ColdFusion query object from a Java class
                                                                          ik1hsr Level 1
                                                                          wait a moment.

                                                                          I delete all TRY/CATCH statament in my code and so all exception are throw to CF.

                                                                          The error change:
                                                                          An exception occurred when instantiating a java object. The cause of this exception was that: Object Instantiation Exception.
                                                                          STACK TRACE
                                                                          java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver at jrunx.util.JRunURLClassLoader.findClass(JRunURLClassLoader.java:161) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:77) at jrunx.util.JRunURLClassLoader.loadClass(JRunURLClassLoader.java:69) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at Pratica.connect(Pratica.java:93) at Pratica.<init>(Pratica.java:29) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java: 39) at.....

                                                                          i thing that cf don't find sqljdbc driver....

                                                                          but in cf administrator,under the system information-->java classpath--<cf classpath i have "C:/Programmi/Driver_SqlServer/sqljdbc_1.1/ita/sqljdbc.jar; "

                                                                          • 38. Problem with return a ColdFusion query object from a Java class
                                                                            ik1hsr Level 1
                                                                            if i write this cf code

                                                                            <cfset try=createObject("java","com.microsoft.sqlserver.jdbc.SQLServerDriver").init()>
                                                                            <cfdump var="#try#">

                                                                            CF find the class and print all method about this SQLServerDriver class!!!!!!!!!!!!!!!

                                                                            • 39. Re: Problem with return a ColdFusion query object from a Java class
                                                                              cf_dev2 Level 1
                                                                              Did you try the new code with getVersion()? I'm thinking CF is still using the old class.
                                                                              1 2 Previous Next