<?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>m-eken &#187; eclipse</title>
	<atom:link href="http://m-eken.com/tag/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>http://m-eken.com</link>
	<description>&#34;I am a dreamer. Seriously, I&#039;m living on another planet.&#34;</description>
	<lastBuildDate>Wed, 05 Oct 2011 19:17:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>MySQL &amp; Swing, Eclipse</title>
		<link>http://m-eken.com/2008/11/22/mysql-swing-eclipse/</link>
		<comments>http://m-eken.com/2008/11/22/mysql-swing-eclipse/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 19:24:31 +0000</pubDate>
		<dc:creator>Eken</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://m-eken.com/?p=330</guid>
		<description><![CDATA[Download the current version of mysql-connector-java from the MySQL products. And unzip the files somewhere. Create a new Java Project in Java Eclipse. Select the project and right clik and select Import, or follow File -&#62; Import. In Import window select &#8220;Archive File&#8221;  and click Next button.  Press Browse button and find the mysql-connector-java-5.1.7-bin.jar file [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Download the current version of mysql-connector-java from the <a href="http://www.mysql.com/products/connector/j/">MySQL products</a>. And unzip the files somewhere. Create a new Java Project in Java Eclipse. Select the project and right clik and select Import, or follow File -&gt; Import. In Import window select &#8220;Archive File&#8221;  and click Next button.  Press Browse button and find the mysql-connector-java-5.1.7-bin.jar file where were you unzip. And click Finish.  Create new package such as Pack. Create new class such as &#8220;MySQL_Swing&#8221; and select &#8220;public static void main(String[] args)&#8221; and then click the Finish button. And write your codes. Following is my sample MySQL_Swing.java codes. I write it for WordPress database.</p>
<p>Sample</p>
<p>Database name: ss3bf</p>
<p>User name: user</p>
<p>Pass: password</p>
<p>SQL Query:  SELECT display_name, user_email,user_nicename FROM wp_users<br />
<strong>Code:</strong></p>
<p><code>package pack;import java.awt.Dimension;<br />
import java.awt.event.ActionEvent;<br />
import java.awt.event.ActionListener;<br />
import java.sql.Connection;<br />
import java.sql.DriverManager;<br />
import java.sql.ResultSet;<br />
import java.sql.Statement;import javax.swing.BorderFactory;<br />
import javax.swing.JButton;<br />
import javax.swing.JEditorPane;<br />
import javax.swing.JFrame;<br />
import javax.swing.JPanel;<br />
import javax.swing.JTextField;public class MySQL_Swing extends JPanel implements ActionListener {<br />
JButton button;<br />
JTextField driver, url, user, pass;<br />
JEditorPane status,sql;<br />
/////// Window objects ///////<br />
public MySQL_Swing(){<br />
url=new JTextField(20);<br />
url.setText("jdbc:mysql://localhost:3306/ss3bf");<br />
sql=new JEditorPane();<br />
sql.setPreferredSize(new Dimension(250,60));<br />
sql.setBorder(BorderFactory.createEtchedBorder(1));<br />
sql.setText("SELECT display_name, user_email,user_nicename FROM wp_users");<br />
user=new JTextField(5);<br />
user.setText("user");<br />
pass=new JTextField(5);<br />
pass.setText("password");<br />
status=new JEditorPane();<br />
status.setPreferredSize(new Dimension(250,250));<br />
status.setBorder(BorderFactory.createEtchedBorder(1));<br />
status.setAutoscrolls(true);<br />
status.setText("Ready \r ");<br />
button=new JButton("Button");<br />
button.setActionCommand("action1");<br />
button.addActionListener(this);<br />
add(url);<br />
add(sql);<br />
add(user);<br />
add(pass);<br />
add(button);<br />
add(status);<br />
}<br />
/////// Make Window ///////<br />
private static void makeWin(){<br />
JFrame.setDefaultLookAndFeelDecorated(true);<br />
JFrame win=new JFrame("MySQL &amp; Swing");<br />
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br />
MySQL_Swing floor=new MySQL_Swing();<br />
floor.setOpaque(true);<br />
win.setContentPane(floor);<br />
win.pack();<br />
win.setSize(300,410);<br />
win.setLocation(350, 300);<br />
win.setVisible(true);<br />
}<br />
//////// Action //////<br />
public void actionPerformed(ActionEvent e){<br />
if("action1".equals(e.getActionCommand())){<br />
try{<br />
status.setText("\r Loading driver... \r "+status.getText());<br />
Class.forName("com.mysql.jdbc.Driver").newInstance();<br />
status.setText("\r driver loaded. \r "+status.getText());<br />
status.setText("\r Connecting... \r "+status.getText());<br />
Connection conn=DriverManager.getConnection(url.getText(),user.getText(),pass.getText());<br />
status.setText("\r Connected. \r "+status.getText());<br />
Statement sqlquery=conn.createStatement();<br />
status.setText("\r Statement ready. \r "+status.getText());<br />
ResultSet rs=sqlquery.executeQuery(sql.getText());<br />
while(rs.next()){<br />
status.setText(rs.getString("display_name")+" \r "+status.getText());<br />
}<br />
status.setText("Results: \r"+status.getText());<br />
conn.close();<br />
}catch(Exception e1){<br />
status.setText(e1.getStackTrace().toString());<br />
}<br />
}<br />
}<br />
//////////////<br />
public static void main(String[] args) {<br />
makeWin();<br />
}}</code></p>
<p><strong>File list:</strong><code><br />
Directory of C:\Users\Y\workspace\Mysql-Swing<br />
.classpath<br />
.project<br />
&lt;DIR&gt;bin<br />
&lt;DIR&gt;com<br />
&lt;DIR&gt;META-INF<br />
<strong>mysql-connector-java-5.1.7-bin.jar</strong><br />
mysql-swing.jar<br />
&lt;DIR&gt;org<br />
&lt;DIR&gt;src</code></p>
<p><strong>Screenshots:</strong></p>
<div class="wp-caption alignnone" style="width: 338px"><a href="http://m-eken.com/wp-content/depo/11/mysql_swing.png"><img title="MySQL Swing" src="http://m-eken.com/wp-content/depo/11/mysql_swing.png" alt="MySQL Swing" width="328" height="249" /></a><p class="wp-caption-text">MySQL &amp; Swing</p></div>
<div class="wp-caption alignnone" style="width: 310px"><a href="http://m-eken.com/wp-content/depo/11/mysql_swing2.png"><img title="MySQL Swing" src="http://m-eken.com/wp-content/depo/11/mysql_swing2.png" alt="MySQL Swing" width="300" height="440" /></a><p class="wp-caption-text">MySQL &amp; Swing</p></div>
<p><strong>Download:</strong> Whith source <a href="http://m-eken.com/wp-content/depo/11/Mysql-Swing.zip">Mysql-Swing.zip</a></p>
<p><strong>References:</strong></p>
<p><a href="http://www.cs.wcupa.edu/~rkline/mysql-java-win.html">http://www.cs.wcupa.edu/~rkline/mysql-java-win.html</a></p>
<p><a href="http://www.neowin.net/forum/index.php?showtopic=697864" target="_blank">http://www.neowin.net/forum/index.php?showtopic=697864</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m-eken.com/2008/11/22/mysql-swing-eclipse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

