Code Search for Developers
 
 
  

ij2.html from CSDerby at Krugle


Show ij2.html syntax highlighted

<html>
<head>
<title>Using ij to run SQL scripts</title>
</head>
<body>
<h2>Using ij to run SQL scripts</h2>
<p>
<b>ij</b> scripts, files that end in an .sql extension and contain SQL
commands, can be run using the Derby plug-ins.
This allows you to use SQL scripts containing multiple commands
and run them in a single execution of <b>ij</b>.
</p>
<h3>Follow these steps to run an SQL script:</h3>
<ul>
<li>
Create a script which contains SQL commands and save the file with a .sql
extension.  Remember to make the database connection your first command 
in the script - no default connection exists. 
<br/><br/>
</li>
<li>
Save the file in your current workspace, under your Java project, or import
it into your workspace.
<br/><br/>
</li>
<li>
Run the script using the menu item <b>Apache Derby, Run SQL script using 'ij'</b>
<br/><br/>
</li>
<li>
The output appears in the <b>ij</b> console window.
<br/><br/>
</li>
</ul>
<h3>Example of creating and running an SQL script</h3>
<p>
We'll go through a complete example below with an sql file called
<b>restaurants.sql</b>.  This script relies on a table we created in the
help section, <a href="ij.html">Use ij to issue SQL commands.</a>  
Run that SQL prior to completing these steps.
</p>
<p>
From the main Eclipse menu select <b>File, New, File</b>.
</p>
<blockquote>
<img src="images/create_file.GIF" alt="Creating a new file in Eclipse" width="841" height="574"></img>
</blockquote>
<p>
Use the current Java project as the parent folder, for example, myJavaProject.
Name the file <b>restaurants.sql</b>, and click <b>Finish</b>.
</p>
<p>
Now the workspace will look like this.
</p>
<blockquote>
<img src="images/create_restaurant.GIF" alt="Adding an sql file to the Java project" width="899" height="609"></img>
</blockquote>
<p>
Type the following in the restaurants.sql editor window (you may need to
double click the restaurants.sql file to create an editor window to type in.)
</p>
<pre>
connect 'jdbc:derby://localhost:1527/myDB;create=true;user=me;password=mine;';
insert into restaurants values (4, 'Grande Burrito', 'Oakland');
update restaurants set city = 'Ukiah' where name = 'Irifunes';
select * from restaurants;
disconnect;
exit;
</pre>
<p>
Now save the restaurants.sql file so we can run the script.  Use <b>Ctrl + S</b>
in the windows environment to save an open file.  Once the file has been saved
the asterisk will disappear next to the name of the file in the editor.
</p>
<p>
The last step is to run the SQL script.  Right-click the <b>restaurants.sql</b> 
file in the <b>Package Explorer</b> view and select <b>Apache Derby, Run SQL 
Script using 'ij'</b>.
</p>
<blockquote>
<img src="images/restaurant_editor.GIF" alt="Run SQL Script using 'ij'" width="910" height="663"></img>
</blockquote>
<p>
The <b>Console</b> view shows the SQL commands contained in the file
and executing in <b>ij</b> along with the output of the commands.  
</p>

<blockquote>
<img src="images/restaurant_script.GIF" alt="Console view of ij script output" width="910" height="663"></img>
</blockquote>
<p>
</p>

</body>
</html>




See more files for this project here

CSDerby

CSDerby is not CloudScape-Derby(for Java) but rather Derby forked/ported to CSharp. Specifically it is intended to be a native c# Embedded DB for the mono/net platform with the ADO.NET API instead of the JDBC API.

Project homepage: http://sourceforge.net/projects/csharpderbyport
Programming language(s): Java,SQL
License: apache20

  images/
    add_nature.GIF
    completed_javaapp.GIF
    create_class.GIF
    create_file.GIF
    create_restaurant.GIF
    ij_commands.GIF
    new_class.GIF
    properties.gif
    property_sheet.GIF
    remove_nature.GIF
    restaurant_editor.GIF
    restaurant_script.GIF
    run_javaapp.GIF
    server_popup.gif
    shutdown_success.gif
    start_ij.GIF
    start_server.GIF
    start_server_console.gif
    stop_popup.gif
    stop_server.GIF
    sysinfo_output.GIF
    sysinfo_start.GIF
  derby_app.html
  ij.html
  ij2.html
  ij_toc.html
  java_project.html
  nature.html
  nature_toc.html
  properties.html
  remove_nature.html
  resources.html
  server_toc.html
  start_server.html
  start_toc.html
  stop_server.html
  sysinfo.html