<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    <channel>
        <title>Tutorial :: CUBRID Through Eclipse SQL Explorer</title>
        <link>http://www.cubrid.org/?mid=eclipse_sql_explorer</link>
        <description>Tutorial :: CUBRID Through Eclipse SQL Explorer</description>
        <language>en</language>
        <pubDate>Tue, 11 Jan 2011 09:03:31 -0800</pubDate>
        <lastBuildDate>Tue, 27 Mar 2012 07:24:50 -0800</lastBuildDate>
        <generator>XpressEngine 1.4.4.1</generator>
                        										        <item>
            <title>CUBRID Through E...</title>
            <dc:creator>CUBRID</dc:creator>
            <link>http://www.cubrid.org/eclipse_sql_explorer</link>
            <guid isPermaLink="true">http://www.cubrid.org/eclipse_sql_explorer</guid>
                                    <description><![CDATA[<h1>CUBRID Through Eclipse SQL Explorer</h1>

<div class="contents-table">
<h3>Table of Contents</h3>
<ul>
<li><a class="toTop">Back to Top</a></li>
<li><a href="#downloads">Downloads</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#add-jdbc">Add JDBC Driver</a></li>
<li><a href="#create-connection">Create New Connection</a></li>
<ul>
<li><a href="#common-connection-errors">Common Connection Errors</a></li>
</ul>
<li><a href="#using-sql-explorer">Using Eclipse SQL Explorer</a></li>
<ul>
<li><a href="#database-structure">Database Structure</a></li>
<li><a href="#create-table">Create Table Script</a></li>
<li><a href="#database-details">Database Details</a></li>
<li><a href="#sql-editor">SQL Editor</a></li>
<li><a href="#select-results">SELECT Query Results</a></li>
<li><a href="#export-html">Export to HTML</a></li>
<li><a href="#common-sql-errors">Common SQL Errors</a></li>
</ul>
<li><a href="#filters">Database Structure Filters</a></li>
<li><a href="#getting-help">Getting Help</a></li>
<li><a href="#see-also">See also</a></li>
</ul>
</div>

<p><a href="http://eclipsesql.sourceforge.net" target="_blank">Eclipse SQL Explorer</a> is a thin SQL client that allows you to query and browse any JDBC compliant database, including CUBRID. The difference between Eclipse SQL Explorer and other similar tools seems to be its surprisingly fast perfomance. I have got to use other tools, but this one caught my attention with its speed. So, give it a try and you will see yourself.</p>

<p>This Eclipse SQL Editor is open source and hosted on Sourceforge.net. You can download it from the links below.</p>

<h2 id="downloads">Downloads</h2>

<p>Eclipse SQL Editor is available in two types:</p>

<table class="blackcap rowbg">
<thead>
<tr>
<td>Type</td>
<td>Eclipse SQL Editor</td>
<td>Size</td>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2">Standalone Client</td>
<td><a href="https://sourceforge.net/projects/eclipsesql/files/SQL%20Explorer%20RCP%20(inc%20JRE)/" target="_blank">SQL Explorer RCP (inc JRE)</a></td>
<td>~77.0 MB</td>
</tr>
<tr>
<td><a href="https://sourceforge.net/projects/eclipsesql/files/SQL%20Explorer%20RCP%20(exc%20JRE)/" target="_blank">SQL Explorer RCP (exc JRE)</a></td>
<td>~44.2 MB</td>
</tr>
<tr>
<td>Eclipse Plugin</td>
<td><a href="https://sourceforge.net/projects/eclipsesql/files/SQL%20Explorer%20Plugin/" target="_blank">SQL Explorer Plugin</a></td>
<td>~11.5 MB</td>
</tr>
</tbody>
</table>

<h2 id="installation">Installation</h2>

<p>Before we proceed, make sure you have already installed the CUBRID Database. Otherwise, download it from <a href="/downloads">http://www.cubrid.org/downloads</a> and follow the <a href="/tutorials#getting-started">quick installation guide</a>.</p>

<h3>Standalone Client</h3>

<p>To install the <b>Standalone Client</b>, download <b>Eclipse SQL Explorer RCP</b> from the link above, then extract the zipfile and launch <b>sqlexplorer.exe</b> to start the application.</p>

<h3>Eclipse Plugin</h3>

<p>To install the <b>Eclipse Plugin</b>, download <b>Eclipse SQL Explorer plugin</b> and extract the zip file in your eclipse directory (requires Eclipse 3.2 or better). After restarting eclipse with the <b>-clean</b> option, a new SQL Explorer perspective should be available.</p>

<h4>Eclipse Update Site</h4>

<p>You can install and update Eclipse SQL Explorer via the eclipse update mechanism. The update site for Eclipse SQL Explorer is <b>http://eclipsesql.sourceforge.net/</b>.</p>

<h2>Start Eclipse SQL Explorer</h2>

<p>This time we will show how to use Eclipse SQL Explorer in a standalone mode. I downloaded the version without all the JAR libraries because I do not need them all. I will use only CUBRID JDBC Driver in this tutorial. First launch the <b>sqlexplorer.exe</b> executable file. You should see the main window as shown below.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-main-window.png" alt="SQL Explorer Main Window" width="725" height="513" editor_component="image_link"/></p>

<h2 id="add-jdbc">Add JDBC Driver</h2>

<p>This step can be performed only once when you launch the program for the first time. Let's just check if CUBRID JDBC (or any other driver you want) is present. Choose <b>File</b> ⇒ <b>Preferences</b>.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-preferences.png" alt="SQL Explorer Preferences" width="216" height="225" editor_component="image_link"/></p>

<p>Then the Preferences window will popup which will display all kinds of JDBC Drivers available.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-preferences-window.png" alt="SQL Explorer Preferences Window" width="635" height="742" editor_component="image_link"/></p>

<p>This time almost all of them are market with red cross icon because I have downloaded the version without JAR libraries. Quickly skim over and if CUBRID JDBC is not available, click on <b>Add</b> button on the right. You will see the following window.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-create-new-driver.png" alt="Create New Driver" width="518" height="493" editor_component="image_link"/></p>

<p>In the new window enter a <b>name</b> for the new driver (e.g. <b>CUBRID JDBC Driver</b>). For <b>Example URL</b> field add <b>jdbc:cubrid:&lt;hostname&gt;:33000:&lt;dbname&gt;:&lt;username&gt;:&lt;password&gt;:</b>. The variables between <b>&lt;&gt;</b> angle brakets will give you a hint that instead of them later when creating a new connection you need to include the actual values. We will see it later. Now we need to add the JDBC driver. For this, click on the <b>Extra Class Path</b> tab and click on the <b>Add JARs...</b> button to browser for the CUBRID JDBC Driver.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/change-driver.png" alt="Change Driver" width="561" height="504" editor_component="image_link"/></p>

<p>In the new Explorer Window locate the CUBRID JDBC Driver which is often located in <b>c:\CUBRID\jdbc\cubrid_jdbc.jar</b> in Windows OS, or in <b>/home/CUBRID/jdbc/cubrid_jdbc.jar</b> in Debian based Linux OS, or in <b>/opt/cubrid/jdbc/cubrid_jdbc.jar</b> in Redhat Linux.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/browse-cubrid-jdbc-driver.PNG" alt="Browse CUBRID JDBC Driver" width="363" height="218" editor_component="image_link"/></p>

<p>Then press the <b>List Drivers</b> button to automatically list the <b>Driver Class Name</b> in the text field below.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-list-drivers.png" alt="List Drivers" width="561" height="504" editor_component="image_link"/></p>

<p>This is all. The CUBRID JDBC Driver has been added. Now if you want to make this driver the default driver, so that every time you create a new connection this driver is chose by default, then press on the <b>Set Default</b> button on the right. Then press <b>OK</b>.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-cubrid-jdbc-driver.png" alt="Preferences" width="635" height="742" editor_component="image_link"/></p>

<h2 id="create-connection">Create New Connection</h2>

<p>To establish a new connection click on the <b>Create New Connection Profile</b> button.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/create-new-connection-button.png" alt="Preferences" width="300" height="181" editor_component="image_link"/></p>

<p>In the new connection window fill out all the required fields. Enter any <b>Name</b> for your connection. The CUBRI JDBC Driver should be automatically selected if you chose it before and pressed the <b>Set Default</b> button in the preferences. Otherwise, select manually.</p>

<p>In the <b>URL</b> field you should first see the previous <b>jdbc:cubrid:&lt;hostname&gt;:33000:&lt;dbname&gt;:&lt;username&gt;:&lt;password&gt;:</b> template you have entered before. So, instead of <b>&lt;hostname&gt;</b> enter your host name or IP (if CUBRID is installed locally, then enter <b>localhost</b>). The port number by default is 33000, but sometimes it is 8001. Instead of <b>&lt;dbname&gt;</b> enter your database name (in this case we will connect to the <b>demodb</b> database which comes be default with CUBRID). Instead of <b>&lt;username&gt;</b> enter your database username (for the <b>demodb</b> database it is <b>dba</b>). Instead of <b>&lt;password&gt;</b> enter your database username password (the <b>demodb</b> database does not require password, so you can leave it blank). As a result you should get the connection URL like this: <b>jdbc:cubrid:localhost:33000:demodb:dba::</b>.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-create-new-connection.png" alt="Create New Connection Profile" width="525" height="405" editor_component="image_link"/></p>

<p>Optionally you can choose to <b>Auto Logon</b>, <b>AutoCommit</b>, etc. Press OK to connect to the database.</p>

<h3 id="common-connection-errors">Common Connection Errors</h3>

<h4>Cannot connect to a broker</h4>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/check-url-cannot-connect-to-broker.png" alt="Cannot connect to a broker" width="532" height="210" editor_component="image_link"/></p>

<p>If you see this error when you try to connect to the database, it means something is wrong with your <b>Connection String/URL</b>. Make sure it is correct.</p>

<h4>Failed to connect to database server, 'demodb', on the following host(s): localhost</h4>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-connection-failed.png" alt="Failed to connect to database server, 'demodb', on the following host(s): localhost" width="532" height="210" editor_component="image_link"/></p>

<p>If you see this error when you try to connect to the database, it means your database has not been started. Type <b>cubrid service start</b> to start the CUBRID Service and <b>cubrid server start demodb</b> to start the <b>demodb</b> database.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/346/command%20line%20demodb.PNG" alt="Start the CUBRID Service and Database" width="355" height="270" editor_component="image_link"/></p>

<h2 id="using-sql-explorer">Using Eclipse SQL Explorer</h2>

<p>Once you connect to the database the main window should look like this.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-explorer-connected.png" alt="Eclipse SQL Example" width="725" height="580" editor_component="image_link"/></p>

<h3 id="database-structure">Database Structure</h3>

<p>You can view the list of <b>Tables</b> and <b>Views</b> in the <b>Database Structure</b> panel on the right.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/database-structure.png" alt="Database Structure" width="383" height="720" editor_component="image_link"/></p>

<h4 id="create-table">Create Table Script</h4>

<p>Right click on any table to see possible actions you can apply to it such as <b>Create Table Script</b>. This will generate an SQL script to create the selected table.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/generate-create-script.png" alt="Create Table Script" width="594" height="412" editor_component="image_link"/></p>

<h3 id="database-details">Database Details</h3>

<p>When you click on any table in the Database Structure panel, you can see its details in the <b>Database Details</b> panel.</p>

<h4>Table Columns</h4>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/database-details.png" alt="Table Columns" width="725" height="364" editor_component="image_link"/></p>

<h4>Preview Records</h4>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/records-preview.png" alt="Preview Records" width="725" height="381" editor_component="image_link"/></p>

<h4>Exported (Foreign) Keys</h4>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/foreign-keys.png" alt="Foreign Keys" width="725" height="290" editor_component="image_link"/></p>

<h3 id="sql-editor">SQL Editor</h3>

<p>Eclipse SQL Explorer comes with built in SQL Editor tool which is capable of highlighting the keywords.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/sql-editor.png" alt="SQL Editor" width="725" height="165" editor_component="image_link"/></p>

<h3 id="select-results">SELECT Query Results</h3>

<p>If you execute any query, Eclipse SQL Explorer return the results really fast. This is what I like in it.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/export-results.png" alt="SELECT Query Results" width="722" height="377" editor_component="image_link"/></p>

<p class="important">Notice that with CUBRID you need to use single quotes for strings in your SQL queries.</p>

<h4 id="export-html">Export to HTML</h4>

<p>You can also right click on the panel to perform various operations such as <b>Export to HTML</b>. The results are displayed in a very neat HTML page.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/html-export-view.png" alt="Export to HTML" width="429" height="421" editor_component="image_link"/></p>

<h4 id="common-sql-errors">Common SQL Errors</h4>

<p>Often users encounter difficulties to execute SQL queries in CUBRID. The common mistake the make is use the double quotes to enclose strings. This is wrong in CUBRID. This will show you something like the error shown below.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/error-executing-sql.png" alt="Error Executing SQL" width="532" height="152" editor_component="image_link"/></p>

<p class="important">Remeber to use single quotes for strings in your SQL queries.</p>

<h3 id="filters">Database Structure Filters</h3>

<p>One of the nice features in Eclipse SQL Explorer is its ability to filter the tables or views which are displayed in the Database Structure panel. For instance, in every CUBRID database there are <b>System Tables</b>, which you as a DBA or a developer almost never need. So, sometimes you want to just hide them to have wider area for your own tables. To do that click on the <b>Filter</b> button on the <b>top right corner of the Database Structure</b> panel.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/select-filter.png" alt="Filter" width="381" height="313" editor_component="image_link"/></p>

<p>Choose which tables you want to hide.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/filter-options.png" alt="Filter: Hide folders" width="396" height="458" editor_component="image_link"/></p>

<p>As you can see no more <b>System Tables</b> in the panel.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/167/004/filter-out-system-tables.png" alt="Filtered Database Structure" width="378" height="321" editor_component="image_link"/></p>

<h2 id="getting-help">Getting Help</h2>

<p>If you have any questions related to Eclipse SQL Explorer, post your message to <a href="http://sourceforge.net/forum/?group_id=132863" target="_blank">Eclipse SQL Explorer Forum</a> or to <a href="/?mid=forum&amp;category=195523&amp;act=dispForumContent" target="_blank">CUBRID Apps &amp; Tools forum</a>.</p>

<h2 id="see-also">See also</h2>

<ul>
<li><a href="http://www.sqlexplorer.org/" target="_blank">SQL Explorer</a></li>
<li><a href="/tutorials">CUBRID Tutorials</a></li>
</ul>]]></description>
                        <pubDate>Tue, 11 Jan 2011 08:04:00 -0800</pubDate>
                                </item>
            </channel>
</rss>
