Subject | Re: Jaybird Problem |
---|---|
Author | daniel_baylon <daniel_baylon@yahoo.com> |
Post date | 2003-02-26T22:15:19Z |
Last message was not explicit, this is my case:
1) Build a java class (Bean) which provide access to database, this
is an example:
------------------------------------------------------------
public class SiteData{
private Connection dbData;
private PreparedStatement qrData;
private ResultSet rsData;
public void openDB(){
Class.forName(JayBirdDriver);
dbData = DriverManager.getConnection(JayBirdURL, "dbUsr", "dbPwd");
dbData.setAutoCommit(false);
}
public void closeDB(){
dbData.close();
}
public void insertData(int pData1, String pData2){
qrData = dbData.prepareStatement("INSERT INTO tbl " +
" VALUES (pData1, pData2)");
qrData.executeUpdate();
dbData.commit();
}
public String[] getData(){
String[] sData;
qrData = dbData.prepareStatement("SELECT dato1 " +
" FROM tbl");
rsData = qrData.executeQuery();
while (rsData.next()){
sData = rsData.getString(1);
} // while
rsData.close()
return sData;
}
}
------------------------------------------------------------
2) JayBird Drivers are installed on Tomcat/lib directory, driver is
installed for all Tomcat applications.
3) Under Tomcat/webapps directory exists an application named
jayBird, which contains 3 jsp pages: welcome.jsp, report.jsp,
endAppl.jsp. Each page uses SiteData as session bean, following tag
is included at each page:
<jsp:useBean id="objData" class="SiteData" scope="session" />
4) welcome.jsp calls objData.openDB(), then post (calls) report.jsp
page.
5) report.jsp calls objdata.insertData(), objData.getdata() methods,
then post (calls) endAppl.jsp.
6) endAppl.jsp calls objData.closeDB() method, then invalidate
sesion: session.invalidate();
Those are my cases, I don't know what changes must execute, if you
need more information, please notify me.
Best Regards.
1) Build a java class (Bean) which provide access to database, this
is an example:
------------------------------------------------------------
public class SiteData{
private Connection dbData;
private PreparedStatement qrData;
private ResultSet rsData;
public void openDB(){
Class.forName(JayBirdDriver);
dbData = DriverManager.getConnection(JayBirdURL, "dbUsr", "dbPwd");
dbData.setAutoCommit(false);
}
public void closeDB(){
dbData.close();
}
public void insertData(int pData1, String pData2){
qrData = dbData.prepareStatement("INSERT INTO tbl " +
" VALUES (pData1, pData2)");
qrData.executeUpdate();
dbData.commit();
}
public String[] getData(){
String[] sData;
qrData = dbData.prepareStatement("SELECT dato1 " +
" FROM tbl");
rsData = qrData.executeQuery();
while (rsData.next()){
sData = rsData.getString(1);
} // while
rsData.close()
return sData;
}
}
------------------------------------------------------------
2) JayBird Drivers are installed on Tomcat/lib directory, driver is
installed for all Tomcat applications.
3) Under Tomcat/webapps directory exists an application named
jayBird, which contains 3 jsp pages: welcome.jsp, report.jsp,
endAppl.jsp. Each page uses SiteData as session bean, following tag
is included at each page:
<jsp:useBean id="objData" class="SiteData" scope="session" />
4) welcome.jsp calls objData.openDB(), then post (calls) report.jsp
page.
5) report.jsp calls objdata.insertData(), objData.getdata() methods,
then post (calls) endAppl.jsp.
6) endAppl.jsp calls objData.closeDB() method, then invalidate
sesion: session.invalidate();
Those are my cases, I don't know what changes must execute, if you
need more information, please notify me.
Best Regards.