<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Neyric.com &#187; serverside</title>
	<atom:link href="http://neyric.com/tag/serverside/feed/" rel="self" type="application/rss+xml" />
	<link>http://neyric.com</link>
	<description>projects, programming, blogging...</description>
	<lastBuildDate>Sat, 29 Jan 2011 19:51:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to setup a mysql data source for Persevere</title>
		<link>http://neyric.com/2008/07/31/how-to-setup-a-mysql-data-source-for-persevere/</link>
		<comments>http://neyric.com/2008/07/31/how-to-setup-a-mysql-data-source-for-persevere/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 14:29:36 +0000</pubDate>
		<dc:creator>neyric</dc:creator>
				<category><![CDATA[Server-side javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Persevere]]></category>
		<category><![CDATA[serverside]]></category>

		<guid isPermaLink="false">http://javascript.neyric.com/blog/?p=75</guid>
		<description><![CDATA[If you don&#8217;t know Persevere yet, check out its impressive list of features (JSONPath/JSON-RPC/Comet support, etc&#8230;). Here is a short tutorial to expose your MySQL tables through the persevere JSON REST interface. Download persevere and unzip it. Download the JDBC &#8230; <a href="http://neyric.com/2008/07/31/how-to-setup-a-mysql-data-source-for-persevere/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://persevere.sitepen.com/res/persevere.png" alt="Persevere logo" width="410" height="57" /></p>
<p>If you don&#8217;t know <a href="http://persevere.sitepen.com/">Persevere</a> yet, check out its impressive list of features (JSONPath/JSON-RPC/Comet support, etc&#8230;).</p>
<p>Here is a short tutorial to expose your MySQL tables through the persevere JSON REST interface.</p>
<ol>
<li>Download <a href="http://code.google.com/p/persevere-framework/">persevere</a> and unzip it.</li>
<li>Download the <a href="http://dev.mysql.com/downloads/connector/j/5.1.html">JDBC driver for MySQL</a> and put the jar file into the &#8220;persevere/lib&#8221; folder.</li>
<li>Create a new file in &#8220;persevere/WEB-INF/config&#8221; named &#8220;myDatabase.json&#8221;</li>
<li>We will now configure the data source: (replace &#8220;myDatabase&#8221; and &#8220;myTable&#8221; by your database and table names.)<code><br />
({<br />
"id":"myDatabase.json",<br />
"sources": [<br />
{<br />
"name":"myTable",<br />
"sourceClass":"org.persvr.datasource.DatabaseTableDataSource",<br />
"driver":"com.mysql.jdbc.Driver",<br />
"connection":<br />
"jdbc:mysql://localhost/myDatabase?user=myDbUser&amp;pass=",<br />
"table":"myTable",<br />
"idColumn":"id",<br />
"dataColumns": [<br />
"lastname",<br />
"firstname",<br />
...and so on with your table columns<br />
],<br />
"schema":{<br />
"data":{"$ref":"../</code><code>myTable</code><code>/"}<br />
}<br />
}<br />
]<br />
}</code>Don&#8217;t forget to change your database user name and password !</li>
<li>run persevere (&#8220;java -jar start.jar&#8221;) and visit the following pages:
<ul>
<li>http://localhost:8080/myTable</li>
<li>http://localhost:8080/myTable/</li>
<li>http://localhost:8080/myTable/1</li>
</ul>
</li>
</ol>
<p>What to do next ?</p>
<ul>
<li>Add other tables: &#8220;sources&#8221; is an array !</li>
<li>Use UTF8:  Adds the following at the end of  the connection string: <code>&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8</code></li>
<li>Add methods to the class or to its prototype (take a look at WEB-INF/config/examples.json)</li>
<li>Write a script to auto-generate the config file from a database structure (and post it on the <a href="http://groups.google.com/group/persevere-framework">persevere forum</a>)</li>
<li>Read the <a href="http://persevere.sitepen.com/persevere-client-readme.html">Persevere Javascript Client Documentation</a> and start coding applications !</li>
</ul>
<p>Have fun !</p>
<div class="shr-publisher-138"></div>]]></content:encoded>
			<wfw:commentRss>http://neyric.com/2008/07/31/how-to-setup-a-mysql-data-source-for-persevere/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

