<?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>hugomonteiro.net &#187; database</title>
	<atom:link href="http://hugomonteiro.net/tag/database/feed/" rel="self" type="application/rss+xml" />
	<link>http://hugomonteiro.net</link>
	<description>&#34;When two men in business always agree, one of them is unnecessary.&#34; - William Wrigley Jr.</description>
	<lastBuildDate>Wed, 14 Dec 2011 00:12:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Access DB manager from the PlayFramework</title>
		<link>http://hugomonteiro.net/2011/06/26/access-db-manager-from-the-play-framework/</link>
		<comments>http://hugomonteiro.net/2011/06/26/access-db-manager-from-the-play-framework/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 14:50:09 +0000</pubDate>
		<dc:creator>Hugo Monteiro</dc:creator>
				<category><![CDATA[play]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[dbmanager]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://hugomonteiro.net/?p=387</guid>
		<description><![CDATA[With the new 1.2 version of play, now it&#8217;s possible to see all the tables in the database without needing an external database manager program. I have been developing in play, and I always feel the need of having a database in memory with test data being loaded each time I run the server. With [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="playframework" src="http://www.realjenius.com/wp-content/uploads/2010/03/play.png" alt="The playframework logo" width="177" height="64" />With the new <strong>1.2 version</strong> of <a href="http://www.playframework.org/">play</a>, now it&#8217;s possible to see all the tables in the database without needing an external database manager program.</p>
<p>I have been developing in <a href="http://www.playframework.org/">play</a>, and I always feel the need of having a database in memory with test data being loaded each time I run the server. With this approach, I don&#8217;t need to have a SQL server running and I don&#8217;t need to be worried about changing my database model (for instance, conflict test data), so I just need to change my test data and run the <a href="http://www.playframework.org/">play</a> server again.</p>
<p>The new database manager that <a href="http://www.playframework.org/">playframework</a> uses is called <a href="http://www.h2database.com/">H2</a>. <a href="http://www.h2database.com/">H2</a> is a Java SQL database which allows to access in-memory/embedded/server databases. In my case, which I use a memory database and I have test data already, I just need to have a line in my Application.conf:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">db=mem</div></div>
<p>The second thing is to do to access the <a href="http://www.h2database.com/">H2</a> database manager inside the <a href="http://www.playframework.org/">play</a> is access the <em><strong>http://localhost:9000/@db </strong></em>url (I am supposing that the dev server is running on your localhost). After accessing the database you just need to configure the <a href="http://www.h2database.com/">H2</a> login like the image:</p>
<p><a href="http://hugomonteiro.net/wp-content/uploads/2011/06/h2-server-login.png"><img class="aligncenter size-medium wp-image-388" title="h2-server-login" src="http://hugomonteiro.net/wp-content/uploads/2011/06/h2-server-login-300x212.png" alt="" width="300" height="212" /></a></p>
<p>Now you just need to press the connect button and voilá! <img src='http://hugomonteiro.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>Conclusions:</strong></p>
<ol>
<li>Run your playframework: <strong>play run myproject</strong> (with the &gt;=1.2 version of <a href="http://www.playframework.org">playframework</a>)</li>
<li>Access <strong><em>http://localhost:9000/@db</em></strong></li>
<li>Configure JDBC URL: <strong><em>jdbc:h2:mem:play </em></strong>(you can access other databases, for instance mysql)</li>
<li>Default authentication:<strong> username: sa / Password: (empty)</strong></li>
</ol>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://hugomonteiro.net/2011/06/26/access-db-manager-from-the-play-framework/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Play Framework + Oracle = EASY!</title>
		<link>http://hugomonteiro.net/2010/01/28/oracle-play-framework-easy/</link>
		<comments>http://hugomonteiro.net/2010/01/28/oracle-play-framework-easy/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 12:18:02 +0000</pubDate>
		<dc:creator>Hugo Monteiro</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[play]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[en]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://hugomonteiro.net/?p=277</guid>
		<description><![CDATA[To configure your oracle database using the play framework you need to follow the following steps: Choose the JAR with the drivers according to your oracle&#8217;s database version and put in the lib/ directory of your web application Configure your application.conf file,  located inside the conf/ directory In the JPA Configuration Section you have to [...]]]></description>
			<content:encoded><![CDATA[<p>To configure your oracle database using the <a href="http://www.playframework.org/">play framework</a> you need to follow the following steps:</p>
<ol>
<li>Choose the <a href="http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html">JAR</a> with the drivers according to your oracle&#8217;s database version and put in the <em>lib/</em> directory of your web application</li>
<li>Configure your application.conf file,  located inside the <em>conf/</em> directory
<ul>
<li>In the JPA Configuration Section you have to choose the <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-optional-dialects">JPA (Hibernate) dialect</a>. In my case I was working with oracle10g so i had to insert in the configuration file:
<ul>
<li>
<pre>jpa.dialect=org.hibernate.dialect.Oracle10gDialect</pre>
</li>
</ul>
</li>
<li>Now you just need to add the following lines, according to your database (including username and password).
<ul>
<li>
<pre>db.url=jdbc:oracle:thin:@yourdatabaseserver:1521:dbname
db.driver=oracle.jdbc.driver.OracleDriver
db.user=yourusername
db.pass=yourpassword</pre>
</li>
</ul>
</li>
</ul>
</li>
<li>Now you just need to restart the server. He adds the database drivers automatically to the classpath of the project.</li>
<li>If you want, you can generate <a href="http://www.netbeans.org">Netbeans</a> or <a href="http://www.eclipse.org">Eclipse</a> projects, so you can open this projects with everything configured.</li>
</ol>
<p>Really easy with no XMLs!</p>
]]></content:encoded>
			<wfw:commentRss>http://hugomonteiro.net/2010/01/28/oracle-play-framework-easy/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

