« June 16, 2006 | Main | June 21, 2006 »

June 17, 2006 Archives

June 17, 2006

conn, ife, sop & try


conn
, ife, sop & try
Oh, weird
language, isn't it.
These are the code templates I use
most often.

A code template is a nice feature of
JDeveloper.
You type a shortcut, eg try, followed by the

CTRL+Enter
key combination and the equivalent template code
is added in the source editor,
at the point where your cursor was.
It
will also bring any associated imports.

For example,
typing conn in the source editor followed by the

CTRL+Enter
key combination will add the following code:

String username = "scott";
String password = "tiger";
String thinConn = "jdbc:oracle:thin:@localhost:1521:ORCL";
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(thinConn,username,password);
conn.setAutoCommit(false);
return conn;
and the following imports:
import java.sql.*;
import oracle.jdbc.OracleDriver;

I think it's worth you have a look at all the avalable shortcuts:
select menu Tools --> Preferences..., expand  Code Editor and click  Code Templates.
You can see there the shortcuts with a small description.
Selecting any shortcut displays the code as shown in the followin picture:

CodeTemplates:


I had never defined my own template before, but I'll certainly do, after having read Frank's post in his blog:
How to automatically add the class name and creation date to a Java file

Frank explains there how you can create your own template, and take advantage of variables (new in JDeveloper 10.1.3).
In his example, a variable $file$ will automatically get assigned the name of the Class and $date$ the current date.

By googling, I see that Steve also explained How to Create a Code Template for JSTL Choose.
Great !

About June 2006

This page contains all entries posted to Didier's Blog in June 2006. They are listed from oldest to newest.

June 16, 2006 is the previous archive.

June 21, 2006 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle