Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / June 2004

Tip: Looking for answers? Try searching our database.

SQLJ program ....

Thread view: 
Raquel - 22 Jun 2004 12:04 GMT
ok, this is a SQL program program that runs fine (on DB2). What does it
mean to have iterator declared outside the class declaration (from a Java
perspective, what are we doing here??)...I was under the impression that
import statements were the only statements that could come before the
class statement. Where is it documented that iterator type #sql statements
are to be declared outside the class definition.

import java.sql.*;
import sqlj.runtime.*;
import sqlj.runtime.ref.*;
#sql iterator Named_Iterator(String lastname);

class sqlj2
{
public static void main(String[] args) throws Exception
{
 Named_Iterator namedItr = null;
 String data = "jdbc:db2://localhost:50000/SAMPLE";
 Class.forName("com.ibm.db2.jcc.DB2Driver");                            

 Connection conn = DriverManager.getConnection(data,"user","passwd");
 DefaultContext Ctx = new DefaultContext(conn);
 DefaultContext.setDefaultContext(Ctx);

 #sql namedItr = {SELECT LASTNAME FROM db2admin.EMPLOYEE WHERE WORKDEPT =
'A00'};  
 while (namedItr.next())
 {
  System.out.println("Lastname is: " + namedItr.lastname());
 }
 namedItr.close();
}
}

TIA
Raquel.
Raquel - 22 Jun 2004 12:26 GMT
Never mind..found answer to this. Apparently, during program preparation,
SQLJ generates an iterator 'class' whose name is this identifier. Hence,
an iteration declaration clause can appear anywhere in a java program that
a java class declaration can appear.

Thanks.
Raquel.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.