struct

Halil AKINCI <[email protected]> Mon, 11 Nov 2002 12:54:28 +0200
Newsgroups gmane.comp.java.sun.idl.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C28981.784A0AA0
Content-Type: text/plain;
        charset="windows-1254"
Content-Transfer-Encoding: quoted-printable

Hi,

I'm studying CORBA and I want to develop a simple application. In this =
application I'm connecting an MS Access 2000 database, executing a query =
and obtaining a resultset. I want to set resultset's information to =
struct interface (EmployeeInfo) and send it to client. How can I do =
that? Can any one help me?


-------------------------------------------------------------------------=
------------
module EmployeeApp {

  struct EmployeeInfo {
         wstring name;
         long number;
         double salary;
  };
  exception SQLError {
      wstring message;
  };
  interface Employee {
     EmployeeInfo getEmployee(in long ID) raises (SQLError);
  };
};
---------------------------------------------------------
part oh the employeServer.java
......
//getEmployee method queries database for employee info
public EmployeeInfo getEmployee(int ID) throws SQLError{   =20
   try {
        /*create a JDBC connection*/
        Connection conn =3D =
DriverManager.getConnection("jdbc:odbc:Employee","","");

        /*Create a SQL statement for the database query*/
        PreparedStatement ps =3D conn.prepareStatement ("select number, =
name, salary from employee where number =3D '"+ID+"' ");

        /*return the  result in an EmployeeInfo structure */
?
?
?

------=_NextPart_000_0010_01C28981.784A0AA0
Content-Type: text/html;
        charset="windows-1254"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1254">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm&nbsp;studying CORBA and I want to =
develop a=20
simple application. In this application I'm&nbsp;connecting&nbsp;an MS =
Access=20
2000 database, executing a query and obtaining a resultset. I want to =
set=20
resultset's information to struct interface (EmployeeInfo)&nbsp;and send =
it to=20
client.&nbsp;How can I do that? Can any one help me?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>----------------------------------------------------------------=
---------------------</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>module EmployeeApp {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; struct EmployeeInfo=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wstring=20
name;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long=20
number;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; double=20
salary;<BR>&nbsp; };</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; exception SQLError=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wstring message;<BR>&nbsp; =
};</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; interface Employee=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; EmployeeInfo getEmployee(in long ID) =
raises=20
(SQLError);<BR>&nbsp; };<BR>};</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>---------------------------------------------------------</FONT>=
</DIV>
<DIV><FONT face=3DArial size=3D2>part oh the =
employeServer.java</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>......</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>//getEmployee method queries database =
for employee=20
info</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public EmployeeInfo getEmployee(int ID) =
throws=20
SQLError{&nbsp;&nbsp;&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; try=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*create a JDBC=20
connection*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Connection =
conn =3D=20
DriverManager.getConnection("jdbc:odbc:Employee","","");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*Create=20
a SQL statement for the database=20
query*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PreparedStatement =
ps =3D=20
conn.prepareStatement ("select number, name, salary from employee where =
number =3D=20
'"+ID+"' ");</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*return=20
the&nbsp; result in an EmployeeInfo structure */<BR>?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>?</FONT></DIV></BODY></HTML>

------=_NextPart_000_0010_01C28981.784A0AA0--

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff IDL-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".