<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MySql db connection through JavaScript in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163124#M116940</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A href="http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access&lt;/A&gt;&lt;SPAN&gt; describes how (in 2.1.3 and beyond) you can access Java APIs from Javascript running within Alfresco.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 May 2008 14:14:28 GMT</pubDate>
    <dc:creator>pmonks</dc:creator>
    <dc:date>2008-05-19T14:14:28Z</dc:date>
    <item>
      <title>MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163121#M116937</link>
      <description>Hello,Can i connect to db through javascript in Alfresco?I need to fetch some data from db, just read from it.. simple "fetch" of 1 field.. If not possible, what are my second options?Thanks everybody</description>
      <pubDate>Fri, 09 May 2008 12:31:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163121#M116937</guid>
      <dc:creator>msvoren</dc:creator>
      <dc:date>2008-05-09T12:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163122#M116938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;From 2.1.3 on you can access Java APIs from Javascript - see &lt;/SPAN&gt;&lt;A href="http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; This would give you access to the JDBC API (or SpringJDBC or Hibernate or whatever) from Javascript, albeit it won't necessarily be easy to do in a production-grade fashion (eg. exception handling can be difficult to do properly in Javascript).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 May 2008 05:03:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163122#M116938</guid>
      <dc:creator>pmonks</dc:creator>
      <dc:date>2008-05-10T05:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163123#M116939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;found this article:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://peter.michaux.ca/article/3019" rel="nofollow noopener noreferrer"&gt;http://peter.michaux.ca/article/3019&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Appendix 2: talking with the database from the Rhino shell&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I make java file, put it in source, org.alfresco.mysqlconnect; I compile the code..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should work, but I don't know how to call java function with javascript in alfresco..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anybody?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 07:55:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163123#M116939</guid>
      <dc:creator>msvoren</dc:creator>
      <dc:date>2008-05-19T07:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163124#M116940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A href="http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access" rel="nofollow noopener noreferrer"&gt;http://wiki.alfresco.com/wiki/JavaScript_API#Native_Java_API_Access&lt;/A&gt;&lt;SPAN&gt; describes how (in 2.1.3 and beyond) you can access Java APIs from Javascript running within Alfresco.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 14:14:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163124#M116940</guid>
      <dc:creator>pmonks</dc:creator>
      <dc:date>2008-05-19T14:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163125#M116941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;found this article:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://peter.michaux.ca/article/3019" rel="nofollow noopener noreferrer"&gt;http://peter.michaux.ca/article/3019&lt;/A&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Appendix 2: talking with the database from the Rhino shell&lt;BR /&gt;&lt;BR /&gt;I make java file, put it in source, org.alfresco.mysqlconnect; I compile the code..&lt;BR /&gt;&lt;BR /&gt;This should work, but I don't know how to call java function with javascript in alfresco..&lt;BR /&gt;&lt;BR /&gt;Anybody?&lt;BR /&gt;thanks&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I've been making some trials with javascript script calling Java. I put jars in lib folder along with other libs in classpath.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You're done, classes are available!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can use them directly using their full name : &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; java.io.File&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var File = java.io.File&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;function fun(){&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; var myfile =&amp;nbsp; new File("myFile");…&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;importPackage doesn't work in my configuration (Alfresco-2.1CE) (see: &lt;/SPAN&gt;&lt;A href="http://forums.alfresco.com/viewtopic.php?t=9711" rel="nofollow noopener noreferrer"&gt;http://forums.alfresco.com/viewtopic.php?t=9711&lt;/A&gt;&lt;SPAN&gt;). Upgrading Rhino to 1.7R1 seems to be OK as far as I've tried it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the other hand, I don't know how to deal with Java Exceptions and if there are best practices for importing Java classes. I don't know neither how to use the classpath for reading a file from say, extension folder. Answers welcome!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;StÃ©phane&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 May 2008 14:44:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163125#M116941</guid>
      <dc:creator>stebans</dc:creator>
      <dc:date>2008-05-19T14:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163126#M116942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your reply!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I already tried to put this java function in web client's lib file..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe my synthax of calling api from js was not correct.. I will try with your example, will let you know.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2008 11:42:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163126#M116942</guid>
      <dc:creator>msvoren</dc:creator>
      <dc:date>2008-05-21T11:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: MySql db connection through JavaScript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163127#M116943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updating Rhino with Rhino-1.7R1 allowed me to import java packages in 2.1CE, although importPackage/importClass were disabled. I then realized that it was a big security problem… There has been discussion about allowing javascript use java classes if the script is in the classpath, as noted in the wiki&lt;/SPAN&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;As of Alfresco 2.1.3, Javascript scripts stored in the classpath can also leverage the Rhino Javascript interpreter's native Java integration facilities (see the Rhino documentation for more details). For security reasons these mechanisms are completely disabled for Javascript scripts that are stored in the repository.&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;So this fonctionality should be available in Alf-Labs3.0, right? What's wrong with this script 'test.js' calling java, with, say, new java.io.File("…") imported in a script? &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;import resource="classpath:alfresco/extension/test.js"&amp;gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; which complains that "ReferenceError: "java" is not defined"?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Could anyone you show an example, or add one in the cookbook?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;stebans&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Aug 2008 10:04:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/mysql-db-connection-through-javascript/m-p/163127#M116943</guid>
      <dc:creator>stebans</dc:creator>
      <dc:date>2008-08-20T10:04:10Z</dc:date>
    </item>
  </channel>
</rss>

