You can subscribe to this list here.
2000 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(24) |
Oct
(37) |
Nov
(42) |
Dec
(29) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2001 |
Jan
(24) |
Feb
(24) |
Mar
(15) |
Apr
(55) |
May
(99) |
Jun
(70) |
Jul
(197) |
Aug
(329) |
Sep
(81) |
Oct
(141) |
Nov
(100) |
Dec
(157) |
2002 |
Jan
(96) |
Feb
(216) |
Mar
(78) |
Apr
(103) |
May
(29) |
Jun
(193) |
Jul
(130) |
Aug
(215) |
Sep
(262) |
Oct
(655) |
Nov
(1009) |
Dec
(655) |
2003 |
Jan
(413) |
Feb
(939) |
Mar
(527) |
Apr
(538) |
May
(439) |
Jun
(295) |
Jul
(681) |
Aug
(810) |
Sep
(835) |
Oct
(730) |
Nov
(988) |
Dec
(787) |
2004 |
Jan
(559) |
Feb
(480) |
Mar
(749) |
Apr
(565) |
May
(748) |
Jun
(529) |
Jul
(454) |
Aug
(714) |
Sep
(628) |
Oct
(857) |
Nov
(1153) |
Dec
(617) |
2005 |
Jan
(603) |
Feb
(444) |
Mar
(377) |
Apr
(579) |
May
(664) |
Jun
(407) |
Jul
(363) |
Aug
(326) |
Sep
(527) |
Oct
(522) |
Nov
(387) |
Dec
(540) |
2006 |
Jan
(355) |
Feb
(242) |
Mar
(563) |
Apr
(768) |
May
(482) |
Jun
(427) |
Jul
(440) |
Aug
(314) |
Sep
(299) |
Oct
(403) |
Nov
(333) |
Dec
(389) |
2007 |
Jan
(247) |
Feb
(335) |
Mar
(391) |
Apr
(562) |
May
(345) |
Jun
(202) |
Jul
(239) |
Aug
(288) |
Sep
(510) |
Oct
(320) |
Nov
(487) |
Dec
(387) |
2008 |
Jan
(575) |
Feb
(539) |
Mar
(762) |
Apr
(648) |
May
(625) |
Jun
(522) |
Jul
(382) |
Aug
(191) |
Sep
(426) |
Oct
(231) |
Nov
(305) |
Dec
(670) |
2009 |
Jan
(582) |
Feb
(595) |
Mar
(294) |
Apr
(461) |
May
(445) |
Jun
(597) |
Jul
(408) |
Aug
(542) |
Sep
(476) |
Oct
(437) |
Nov
(587) |
Dec
(722) |
2010 |
Jan
(456) |
Feb
(319) |
Mar
(437) |
Apr
(303) |
May
(276) |
Jun
(233) |
Jul
(155) |
Aug
(208) |
Sep
(136) |
Oct
(274) |
Nov
(241) |
Dec
(106) |
2011 |
Jan
(160) |
Feb
(244) |
Mar
(138) |
Apr
(235) |
May
(208) |
Jun
(196) |
Jul
(107) |
Aug
(77) |
Sep
(109) |
Oct
(165) |
Nov
(86) |
Dec
(211) |
2012 |
Jan
(188) |
Feb
(136) |
Mar
(273) |
Apr
(185) |
May
(149) |
Jun
(146) |
Jul
(73) |
Aug
(127) |
Sep
(103) |
Oct
(87) |
Nov
(159) |
Dec
(149) |
2013 |
Jan
(74) |
Feb
(112) |
Mar
(176) |
Apr
(139) |
May
(116) |
Jun
(160) |
Jul
(161) |
Aug
(124) |
Sep
(124) |
Oct
(82) |
Nov
(137) |
Dec
(128) |
2014 |
Jan
(116) |
Feb
(121) |
Mar
(134) |
Apr
(177) |
May
(146) |
Jun
(158) |
Jul
(154) |
Aug
(79) |
Sep
(60) |
Oct
(90) |
Nov
(184) |
Dec
(201) |
2015 |
Jan
(163) |
Feb
(263) |
Mar
(406) |
Apr
(291) |
May
(213) |
Jun
(229) |
Jul
(229) |
Aug
(111) |
Sep
(120) |
Oct
(234) |
Nov
(155) |
Dec
(153) |
2016 |
Jan
(147) |
Feb
(188) |
Mar
(363) |
Apr
(304) |
May
(199) |
Jun
(218) |
Jul
(136) |
Aug
(128) |
Sep
(120) |
Oct
(123) |
Nov
(102) |
Dec
(156) |
2017 |
Jan
(123) |
Feb
(114) |
Mar
(132) |
Apr
(44) |
May
(143) |
Jun
(83) |
Jul
(98) |
Aug
(59) |
Sep
(58) |
Oct
(12) |
Nov
(14) |
Dec
(16) |
2018 |
Jan
(18) |
Feb
(24) |
Mar
(41) |
Apr
(16) |
May
(19) |
Jun
(31) |
Jul
(3) |
Aug
(33) |
Sep
(11) |
Oct
(11) |
Nov
|
Dec
|
2019 |
Jan
(21) |
Feb
(66) |
Mar
(72) |
Apr
(69) |
May
(63) |
Jun
(49) |
Jul
(55) |
Aug
(38) |
Sep
(66) |
Oct
(51) |
Nov
(66) |
Dec
(97) |
2020 |
Jan
(98) |
Feb
(95) |
Mar
(83) |
Apr
(121) |
May
(91) |
Jun
(137) |
Jul
(94) |
Aug
(91) |
Sep
(60) |
Oct
(81) |
Nov
(82) |
Dec
(64) |
2021 |
Jan
(66) |
Feb
(50) |
Mar
(52) |
Apr
(110) |
May
(160) |
Jun
(94) |
Jul
(97) |
Aug
(99) |
Sep
(160) |
Oct
(118) |
Nov
(117) |
Dec
(119) |
2022 |
Jan
(90) |
Feb
(93) |
Mar
(75) |
Apr
(70) |
May
(61) |
Jun
(153) |
Jul
(82) |
Aug
(118) |
Sep
(127) |
Oct
(121) |
Nov
(78) |
Dec
(84) |
2023 |
Jan
(80) |
Feb
(75) |
Mar
(92) |
Apr
(103) |
May
(89) |
Jun
(89) |
Jul
(106) |
Aug
(87) |
Sep
(183) |
Oct
(128) |
Nov
(173) |
Dec
(116) |
2024 |
Jan
(144) |
Feb
(120) |
Mar
(113) |
Apr
(107) |
May
(84) |
Jun
(95) |
Jul
(100) |
Aug
(135) |
Sep
(119) |
Oct
(93) |
Nov
(91) |
Dec
(93) |
2025 |
Jan
(104) |
Feb
(165) |
Mar
(120) |
Apr
(124) |
May
(90) |
Jun
(141) |
Jul
(239) |
Aug
(48) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Neil M. <nm...@us...> - 2001-06-20 16:02:45
|
Update of /cvsroot/firebird/interbase/builds/original In directory usw-pr-cvs1:/tmp/cvs-serv15306/builds/original Modified Files: sfx.jrd Log Message: Fix compile options for Solaris Sparc build. Index: sfx.jrd =================================================================== RCS file: /cvsroot/firebird/interbase/builds/original/sfx.jrd,v retrieving revision 1.4 retrieving revision 1.5 diff -U3 -r1.4 -r1.5 --- sfx.jrd 2001/05/24 04:11:11 1.4 +++ sfx.jrd 2001/06/20 16:02:03 1.5 @@ -907,7 +907,8 @@ gds.bin: gds.c $(CC) -c $(PIC_FLAGS) $(CARBONCORE_DIR_FLAG) $(VERSION_FLAG) \ - -o $*.bin $< + -o $*_temp.o $< + mv $*_temp.o $*.bin grammar.c: grammar.y grammar.o: grammar.c dbg.h jlx.c |
From: Neil M. <nm...@us...> - 2001-06-20 15:59:08
|
Update of /cvsroot/firebird/interbase/jrd In directory usw-pr-cvs1:/tmp/cvs-serv13137/jrd Modified Files: flu.c Log Message: Output the system error message if a UDF library can not be loaded. Index: flu.c =================================================================== RCS file: /cvsroot/firebird/interbase/jrd/flu.c,v retrieving revision 1.9 retrieving revision 1.10 diff -U3 -r1.9 -r1.10 --- flu.c 2001/06/06 23:54:12 1.9 +++ flu.c 2001/06/20 15:58:06 1.10 @@ -866,6 +866,9 @@ /* Module is in the standard UDF directory: load it. */ if (!(mod->mod_handle = dlopen (ib_lib_path, RTLD_LAZY))) { +#ifdef DEV_BUILD + printf("%s\n",dlerror()); +#endif gds__free (mod); return NULL; } |
From: Frank Schlottmann-G. <fs...@us...> - 2001-06-18 22:26:40
|
Update of /cvsroot/firebird/interbase In directory usw-pr-cvs1:/tmp/cvs-serv9537/interbase Modified Files: ChangeLog Log Message: Updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/firebird/interbase/ChangeLog,v retrieving revision 1.43 retrieving revision 1.44 diff -U3 -r1.43 -r1.44 --- ChangeLog 2001/06/11 22:20:01 1.43 +++ ChangeLog 2001/06/18 22:26:38 1.44 @@ -1,3 +1,9 @@ +2001-06-18 11:02 tamlin + + * interbase/jrd/winnt.c: + + Allow DB file sharing again. + 2001-06-11 13:27 tamlin * interbase/jrd/winnt.c: |
From: David J. <d_j...@us...> - 2001-06-18 19:26:34
|
Update of /cvsroot/firebird/interclient/20/dev/interserver In directory usw-pr-cvs1:/tmp/cvs-serv28492 Modified Files: IB_Defines.h IB_Statement.cpp interserver.cpp Log Message: Added sql logging to interserver, thanks to Micael Wyraz (mic...@ev...). Use -l command line switch. Index: IB_Defines.h =================================================================== RCS file: /cvsroot/firebird/interclient/20/dev/interserver/IB_Defines.h,v retrieving revision 1.3 retrieving revision 1.4 diff -U3 -r1.3 -r1.4 --- IB_Defines.h 2001/04/17 12:49:43 1.3 +++ IB_Defines.h 2001/06/18 19:26:30 1.4 @@ -119,4 +119,7 @@ void errorLog (char* what); +//Sql logging by Michael Wyraz +void sqlLog (char* what); + #endif Index: IB_Statement.cpp =================================================================== RCS file: /cvsroot/firebird/interclient/20/dev/interserver/IB_Statement.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- IB_Statement.cpp 2001/02/06 15:31:35 1.2 +++ IB_Statement.cpp 2001/06/18 19:26:30 1.3 @@ -155,7 +155,7 @@ IB_Statement::prepareNoInputNoOutput (const IB_STRING sqlString) { //david jencks 2-4-2001 -// errorLog(sqlString);//uncomment to log all sql statements executed + sqlLog(sqlString);// logging all sql statements if (!stmtHandle_) open (); @@ -195,7 +195,7 @@ const IB_SSHORT16 maxFieldSize) { //david jencks 2-4-2001 -// errorLog(sqlString);//uncomment to log all sql statements executed + sqlLog(sqlString); // logg all sql statements if (!stmtHandle_) Index: interserver.cpp =================================================================== RCS file: /cvsroot/firebird/interclient/20/dev/interserver/interserver.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- interserver.cpp 2001/04/17 12:49:43 1.2 +++ interserver.cpp 2001/06/18 19:26:30 1.3 @@ -48,6 +48,8 @@ #include "NetTCP.h" #include "VersionInformation.h" +bool sql_logging_ = false; + // This is not thread safe. // Just hope that this doesn't happen too often. void errorLog (char* what) @@ -71,6 +73,32 @@ } } + +// michael wyraz, 2001-06-12: added sql logging with parameter "-l" +// This is not thread safe. +// Just hope that this doesn't happen too often. +void sqlLog (char* what) +{ + if (!sql_logging_) return; + // For an InterServer application, this log file goes + // to the proper directory, but for a service on NT, + // the log file goes to win32 or some such system directory. + // !!! When we get time, extract the root directory from + // !!! the registry to prefix interserver.log. + // !!! See ISC_get_registry_var and GetProfileString as used + // !!! in gds.c::gds__prefix and gds.c::gds__log +#ifdef UNIX + FILE* f = fopen ("/usr/interclient/interserver_sql.log", "a"); +#else + FILE* f = fopen ("interserver_sql.log", "a"); +#endif + if (f) { + fprintf (f, "%s\n", what); + fflush (f); + fclose (f); + } +} + // Not thread safe. // This tracing will not work for multiple connections! #ifdef TRACEON @@ -133,7 +161,7 @@ // forked by services manager or by user initiated daemon if (newSockfd != 0) goto fork_start; - + #else register char *s; @@ -172,6 +200,11 @@ EXIT(0); default: + + case 'l': + // sql logging enabled + sql_logging_ = true; + break; Error::err_quit ("unknown command line option: %c", *s); } #endif |
From: David J. <d_j...@us...> - 2001-06-18 13:59:48
|
Update of /cvsroot/firebird/interclient/20/dev/packages/interbase/interclient In directory usw-pr-cvs1:/tmp/cvs-serv12929 Modified Files: PreparedStatement.java Log Message: Changed construction of BigDecimal objects for longs to use correct factory method instead of nonexistent constructor. Problem discovered and fix by Michael Wyraz (mic...@ev...) Index: PreparedStatement.java =================================================================== RCS file: /cvsroot/firebird/interclient/20/dev/packages/interbase/interclient/PreparedStatement.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- PreparedStatement.java 2001/02/03 08:32:31 1.2 +++ PreparedStatement.java 2001/06/18 13:59:45 1.3 @@ -72,8 +72,10 @@ private final static java.math.BigDecimal bdMaxDoubleValue = new java.math.BigDecimal (Double.MAX_VALUE); private final static java.math.BigDecimal bdMinDoubleValue = new java.math.BigDecimal (-Double.MAX_VALUE); // CJL-IB6 add limits for new long types - private final static java.math.BigDecimal bdMaxLongValue = new java.math.BigDecimal (Long.MAX_VALUE); - private final static java.math.BigDecimal bdMinLongValue = new java.math.BigDecimal (Long.MIN_VALUE); + // michael wyraz, 2001-06-12: + //Changed to valueOf factory method from nonexistent constructor. + private final static java.math.BigDecimal bdMaxLongValue = java.math.BigDecimal.valueOf(Long.MAX_VALUE); + private final static java.math.BigDecimal bdMinLongValue = java.math.BigDecimal.valueOf(Long.MIN_VALUE); // CJL-IB6 end change // Called by Connection.close() to mark open statements as closed. @@ -488,7 +490,9 @@ case IBTypes.DECIMAL_INTEGER__: case IBTypes.DECIMAL_INT64__: // CJL-IB6 end change - scaledUpBd = new java.math.BigDecimal (x); + // michael wyraz, 2001-06-12: + //Changed to valueOf factory method from nonexistent constructor. + scaledUpBd = java.math.BigDecimal.valueOf(x); scaledUpBd = scaledUpBd.movePointRight (inputScales_[parameterIndex-1]); scaledUpBd = scaledUpBd.setScale (0, java.math.BigDecimal.ROUND_HALF_DOWN); } @@ -577,7 +581,9 @@ case IBTypes.DECIMAL_INTEGER__: case IBTypes.DECIMAL_INT64__: // CJL-IB6 end change - scaledUpBd = new java.math.BigDecimal (x); + // michael wyraz, 2001-06-12: + //Changed to valueOf factory method from nonexistent constructor. + scaledUpBd = java.math.BigDecimal.valueOf(x); scaledUpBd = scaledUpBd.movePointRight (inputScales_[parameterIndex-1]); scaledUpBd = scaledUpBd.setScale (0, java.math.BigDecimal.ROUND_HALF_DOWN); } |
From: Mike N. <ta...@us...> - 2001-06-18 09:02:07
|
Update of /cvsroot/firebird/interbase/jrd In directory usw-pr-cvs1:/tmp/cvs-serv22937 Modified Files: winnt.c Log Message: Allow DB file sharing again. Index: winnt.c =================================================================== RCS file: /cvsroot/firebird/interbase/jrd/winnt.c,v retrieving revision 1.4 retrieving revision 1.5 diff -U3 -r1.4 -r1.5 --- winnt.c 2001/06/11 11:27:54 1.4 +++ winnt.c 2001/06/18 09:02:05 1.5 @@ -79,7 +79,10 @@ FILE_FLAG_NO_BUFFERING | FILE_FLAG_RANDOM_ACCESS; #elif SUPERSERVER -static const DWORD g_dwShareFlags = 0; // no sharing +// TMN: Can't disable sharing since the engine tries to open the +// isc4.gdb at least twice... +//static const DWORD g_dwShareFlags = 0; // no sharing +static const DWORD g_dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; static const DWORD g_dwExtraFlags = FILE_FLAG_RANDOM_ACCESS; #else static const DWORD g_dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; |
From: David J. <d_j...@us...> - 2001-06-14 04:48:05
|
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/management In directory usw-pr-cvs1:/tmp/cvs-serv7418/org/firebirdsql/management Added Files: FBManager.java FBManagerMBean.java TestFBManager.java Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- FBManager.java ADDED --- --- FBManagerMBean.java ADDED --- --- TestFBManager.java ADDED --- |
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/jgds In directory usw-pr-cvs1:/tmp/cvs-serv7418/org/firebirdsql/jgds Modified Files: ClumpletImpl.java GDS_Impl.java TestGds.java XdrInputStream.java Xdrable.java isc_stmt_handle_impl.java Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. Index: ClumpletImpl.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/ClumpletImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -U3 -r1.1 -r1.2 --- ClumpletImpl.java 2001/05/25 16:18:06 1.1 +++ ClumpletImpl.java 2001/06/14 04:48:01 1.2 @@ -31,6 +31,7 @@ import org.firebirdsql.gds.Clumplet; import java.io.OutputStream; import java.io.IOException; +import java.util.Arrays; public class ClumpletImpl implements Clumplet, Xdrable { @@ -41,13 +42,24 @@ ClumpletImpl(int type, byte[] content) { this.type = type; this.content = content; -// this.length = content.length + 2; //+1 for type byte, +1 for length byte } + + ClumpletImpl(ClumpletImpl c) { + this.type = c.type; + this.content = c.content; + if (c.next != null) { + this.next = new ClumpletImpl(c.next); + } + } public void append(Clumplet c) { - if (next == null) { - next = (ClumpletImpl)c; + ClumpletImpl ci = (ClumpletImpl)c; + if (this.type == ci.type) { + this.content = ci.content; } + else if (next == null) { + next = ci; + } else { next.append(c); } @@ -61,8 +73,8 @@ return content.length + 2 + next.getLength(); } } - + //XDRable public void write(XdrOutputStream out) throws IOException{ out.write(type); out.write(content.length); @@ -72,6 +84,22 @@ } } + //XDRable public void read(XdrInputStream in, int length) {} + + + public boolean equals(Object o) { + if ((o == null) || !(o instanceof ClumpletImpl)) { + return false; + } + ClumpletImpl c = (ClumpletImpl)o; + if (type != c.type || !Arrays.equals(content, c.content)) { + return false; //these have different contents + } + if (next != null) { + return next.equals(c.next);//we have next, compare with c.next + } + return (c.next == null); //contents the same, we have no next, == if c has no next. + } } Index: GDS_Impl.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/GDS_Impl.java,v retrieving revision 1.3 retrieving revision 1.4 diff -U3 -r1.3 -r1.4 --- GDS_Impl.java 2001/05/25 19:46:20 1.3 +++ GDS_Impl.java 2001/06/14 04:48:01 1.4 @@ -160,18 +160,16 @@ private byte[] resp_data; */ + static final int MAX_BUFFER_SIZE = 2024;//4096; //max size for response for ?? + public GDS_Impl() { } // Database functions - - public void isc_create_database(String file_name, - isc_db_handle db_handle, - Clumplet c - /* int dpb_length, - byte[] dpb*/) throws GDSException { +//this one doesn't work. + public void isc_create_database2(String file_name, isc_db_handle db_handle) throws GDSException { isc_db_handle_impl db = (isc_db_handle_impl) db_handle; if (db == null) { @@ -179,32 +177,24 @@ } -/* if (dpb_length > 0 && dpb == null) { - throw new GDSException(isc_bad_dpb_form); - }*/ + DbAttachInfo dbai = new DbAttachInfo(file_name); + connect(db, dbai); + isc_tr_handle tr = get_new_isc_tr_handle(); + String s = "CREATE DATABASE '" + dbai.getFileName() + "' USER 'sysdba' PASSWORD 'masterkey'"; + System.out.println(s); + isc_dsql_execute_immediate(db, tr, s, GDS.SQL_DIALECT_CURRENT, null); + } + + public void isc_create_database(String file_name, + isc_db_handle db_handle, + Clumplet c) throws GDSException { + + isc_db_handle_impl db = (isc_db_handle_impl) db_handle; - /* - file_name.trim(); - String node_name; - int sep = file_name.indexOf(':'); - if (sep == 0 || sep == file_name.length() - 1) { - throw new GDSException(isc_bad_db_format, ""); + if (db == null) { + throw new GDSException(isc_bad_db_handle); } - int port = 3050; - if (sep < 0) { - node_name = "localhost"; - } else { - node_name = file_name.substring(0, sep); - file_name = file_name.substring(sep + 1); - sep = node_name.indexOf('/'); - if (sep == 0 || sep == node_name.length() - 1) { - throw new GDSException(isc_bad_db_format, ""); - } - if (sep > 0) { - port = Integer.parseInt(node_name.substring(sep + 1)); - node_name = node_name.substring(0, sep); - } - }*/ + DbAttachInfo dbai = new DbAttachInfo(file_name); connect(db, dbai); @@ -531,6 +521,7 @@ stmt.rsr_rdb = db; db.rdb_sql_requests.addElement(stmt); + stmt.allRowsFetched = false; } @@ -539,9 +530,9 @@ throw new GDSException(isc_wish_list); } - public void isc_dsql_describe(isc_stmt_handle stmt_handle, - int da_version, - XSQLDA xsqlda) throws GDSException { + public XSQLDA isc_dsql_describe(isc_stmt_handle stmt_handle, + int da_version/*, + XSQLDA xsqlda*/) throws GDSException { byte[] describe_select_info = new byte[] { isc_info_sql_select, isc_info_sql_describe_vars, @@ -557,19 +548,19 @@ isc_info_sql_describe_end }; // byte[] buffer = new byte[32000]; - int buffer_length = 32000; + int buffer_length = MAX_BUFFER_SIZE; byte[] buffer = isc_dsql_sql_info(stmt_handle, describe_select_info.length, describe_select_info, buffer_length/*, buffer*/); - parseSqlInfo(buffer, xsqlda); + return parseSqlInfo(buffer); } - public void isc_dsql_describe_bind( isc_stmt_handle stmt_handle, - int da_version, - XSQLDA xsqlda) throws GDSException { + public XSQLDA isc_dsql_describe_bind( isc_stmt_handle stmt_handle, + int da_version/*, + XSQLDA xsqlda*/) throws GDSException { byte[] describe_bind_info = new byte[] { isc_info_sql_bind, isc_info_sql_describe_vars, @@ -585,12 +576,14 @@ isc_info_sql_describe_end }; // byte[] buffer = new byte[32000]; - int buffer_length = 32000; + int buffer_length = MAX_BUFFER_SIZE; byte[] buffer = isc_dsql_sql_info(stmt_handle, describe_bind_info.length, describe_bind_info, buffer_length/*, buffer*/); - parseSqlInfo(buffer, xsqlda); +// return parseSqlInfo(buffer/*, xsqlda*/); + ((isc_stmt_handle_impl)stmt_handle).in_sqlda = parseSqlInfo(buffer); + return ((isc_stmt_handle_impl)stmt_handle).in_sqlda; } @@ -626,8 +619,8 @@ db.out.writeInt(tr.rtr_id); writeBLR(db, in_xsqlda); - db.out.writeInt(0); - db.out.writeInt(((in_xsqlda == null) ? 0 : 1)); + db.out.writeInt(0); //message number = in_message_type + db.out.writeInt(((in_xsqlda == null) ? 0 : 1)); //stmt->rsr_bind_format if (in_xsqlda != null) { writeSQLData(db, in_xsqlda); @@ -635,7 +628,7 @@ if (out_xsqlda != null) { writeBLR(db, out_xsqlda); - db.out.writeInt(0); + db.out.writeInt(0); //out_message_number = out_message_type } System.out.println("sent"); @@ -651,15 +644,15 @@ } - public void isc_dsql_execute_inmediate( isc_db_handle db_handle, + public void isc_dsql_execute_immediate(isc_db_handle db_handle, isc_tr_handle tr_handle, String statement, int dialect, XSQLDA xsqlda) throws GDSException { - throw new GDSException(isc_wish_list); + isc_dsql_exec_immed2(db_handle, tr_handle, statement, dialect, xsqlda, null); } - public void isc_dsql_exec_inmed2( isc_db_handle db_handle, + public void isc_dsql_exec_immed2(isc_db_handle db_handle, isc_tr_handle tr_handle, String statement, int dialect, @@ -711,7 +704,7 @@ } - public void isc_dsql_fetch(isc_stmt_handle stmt_handle, + public Object[] isc_dsql_fetch(isc_stmt_handle stmt_handle, int da_version, XSQLDA xsqlda) throws GDSException { @@ -726,7 +719,8 @@ throw new GDSException(isc_dsql_sqlda_err); } - if (stmt.rows.size() == 0) { + if (!stmt.allRowsFetched && stmt.rows.size() == 0) { + //Fetch next batch of rows try { System.out.print("op_fetch "); db.out.writeInt(op_fetch); @@ -745,22 +739,22 @@ sqldata_messages = db.in.readInt(); if (sqldata_messages > 0 && sqldata_status == 0) { - readSQLData(db, xsqlda); + stmt.rows.add(readSQLData(db, xsqlda)); - XSQLDA batch_xsqlda = new XSQLDA(xsqlda.sqln); +/* XSQLDA batch_xsqlda = new XSQLDA(xsqlda.sqln); for (int i = 0; i < xsqlda.sqln; i++) { batch_xsqlda.sqlvar[i] = new XSQLVAR(xsqlda.sqlvar[i].sqldata); xsqlda.sqlvar[i].sqldata = null; } - stmt.rows.addElement(batch_xsqlda); + stmt.rows.addElement(batch_xsqlda);*/ } } while (sqldata_messages > 0 && sqldata_status == 0); if (sqldata_status == 100) { - throw new GDSException(sqldata_status); + stmt.allRowsFetched = true; } } @@ -773,11 +767,27 @@ } if (stmt.rows.size() > 0) { - XSQLDA out_xsqlda = (XSQLDA) stmt.rows.elementAt(0); + //Return next row from cache. + Object[] row = (Object[])stmt.rows.remove(0); + for (int i = 0; i < xsqlda.sqld; i++) { + xsqlda.sqlvar[i].sqldata = row[i]; + } + for (int i = xsqlda.sqld; i< xsqlda.sqln; i++) { + //is this really necessary? + xsqlda.sqlvar[i].sqldata = null; + } + return row; +/* XSQLDA out_xsqlda = (XSQLDA) stmt.rows.elementAt(0); stmt.rows.removeElementAt(0); for (int i = 0; i < xsqlda.sqln; i++) { xsqlda.sqlvar[i].sqldata = out_xsqlda.sqlvar[i].sqldata; + }*/ + } + else { + for (int i = 0; i< xsqlda.sqln; i++) { + xsqlda.sqlvar[i].sqldata = null; } + return null; //no rows fetched } } @@ -800,6 +810,13 @@ System.out.println("sent"); receiveResponse(db); + if (option == DSQL_drop) { + stmt.in_sqlda = null; + stmt.out_sqlda = null; + } + stmt.clearRows(); +// stmt.rows.clear(); +// stmt.allRowsFetched = false; } catch (IOException ex) { throw new GDSException(isc_net_read_err); } @@ -807,11 +824,11 @@ } - public void isc_dsql_prepare(isc_tr_handle tr_handle, + public XSQLDA isc_dsql_prepare(isc_tr_handle tr_handle, isc_stmt_handle stmt_handle, String statement, - int dialect, - XSQLDA xsqlda) throws GDSException { + int dialect/*, + xsqlda*/) throws GDSException { isc_tr_handle_impl tr = (isc_tr_handle_impl) tr_handle; isc_stmt_handle_impl stmt = (isc_stmt_handle_impl) stmt_handle; isc_db_handle_impl db = stmt.rsr_rdb; @@ -824,6 +841,11 @@ throw new GDSException(isc_bad_req_handle); } + //reinitialize stmt SQLDA members. + + stmt.in_sqlda = null; + stmt.out_sqlda = null; + byte[] sql_prepare_info = new byte[] { isc_info_sql_select, isc_info_sql_describe_vars, isc_info_sql_sqlda_seq, @@ -838,7 +860,7 @@ isc_info_sql_describe_end }; // byte[] buffer = new byte[32000]; - int buffer_length = 32000; + int buffer_length = MAX_BUFFER_SIZE; try { System.out.print("op_prepare_statement "); db.out.writeInt(op_prepare_statement); @@ -852,7 +874,9 @@ System.out.println("sent"); Response r = receiveResponse(db); // System.arraycopy(resp_data, 0, buffer, 0, resp_data.length); - parseSqlInfo(r.resp_data, xsqlda); +// return parseSqlInfo(r.resp_data); + stmt.out_sqlda = parseSqlInfo(r.resp_data); + return stmt.out_sqlda; } catch (IOException ex) { throw new GDSException(isc_net_read_err); } @@ -1025,7 +1049,7 @@ db.socket.close(); } - private void receiveSqlResponse( isc_db_handle_impl db, + private void receiveSqlResponse(isc_db_handle_impl db, XSQLDA xsqlda) throws GDSException { try { System.out.print("op_sql_response "); @@ -1048,17 +1072,27 @@ private Response receiveResponse(isc_db_handle_impl db) throws GDSException { try { System.out.print("op_response "); - if (readOperation(db) == op_response) { + int op = readOperation(db); + if (op == op_response) { Response r = new Response(); r.resp_object = db.in.readInt(); + System.out.println("op_response resp_object: " + r.resp_object); r.resp_blob_id = db.in.readLong(); + System.out.println("op_response resp_blob_id: " + r.resp_blob_id); r.resp_data = db.in.readBuffer(); + System.out.println("op_response resp_data size: " + r.resp_data.length); + /* for (int i = 0; i < Math.min(r.resp_data.length, 16); i++) { + System.out.println("byte: " + r.resp_data[i]); + }*/ readStatusVector(db); System.out.println("received"); + checkAllRead(db.in);//DEBUG return r; } else { - System.out.println("not received"); - throw new GDSException(isc_net_read_err); + System.out.println("not received: op is " + op); + checkAllRead(db.in); + return null; +// throw new GDSException(isc_net_read_err); } } catch (IOException ex) { ex.printStackTrace(); @@ -1098,6 +1132,7 @@ case isc_arg_interpreted: case isc_arg_string: GDSException ts = new GDSException(db.in.readString()); + System.out.println("readStatusVector string: " + ts.getMessage()); if (head == null) { head = ts; tail = ts; @@ -1110,6 +1145,7 @@ case isc_arg_number: default: int e = db.in.readInt(); + System.out.println("readStatusVector int: " + e); if (e != 0) { GDSException td = new GDSException(e); if (head == null) { @@ -1347,17 +1383,22 @@ (153 * month + 2) / 5 + day + 1721119 - 2400001); } + - private void readSQLData(isc_db_handle_impl db, + //Now returns results in Object[] and in xsqlda.data + //Nulls are represented by null values in Object array, + //but by sqlind = -1 in xsqlda. + private Object[] readSQLData(isc_db_handle_impl db, XSQLDA xsqlda) throws GDSException { // This only works if not (port->port_flags & PORT_symmetric) - + Object[] row = new Object[xsqlda.sqld]; for (int i = 0; i < xsqlda.sqld; i++) { - readSQLDatum(db, xsqlda.sqlvar[i]); + row[i] = readSQLDatum(db, xsqlda.sqlvar[i]); } + return row; } - private void readSQLDatum(isc_db_handle_impl db, + private Object readSQLDatum(isc_db_handle_impl db, XSQLVAR xsqlvar) throws GDSException { try { switch (xsqlvar.sqltype & ~1) { @@ -1410,6 +1451,16 @@ xsqlvar.sqlind = db.in.readInt(); + if (xsqlvar.sqlind == 0) { + return xsqlvar.sqldata; + } + else if (xsqlvar.sqlind == -1) { + return null; + } + else { + throw new GDSException("invalid sqlind value: " + xsqlvar.sqlind); + } + } catch (IOException ex) { throw new GDSException(isc_net_read_err); } @@ -1449,15 +1500,18 @@ } - private void parseSqlInfo(byte[] info, XSQLDA xsqlda) throws GDSException { + private XSQLDA parseSqlInfo(byte[] info) throws GDSException { + XSQLDA xsqlda = new XSQLDA(); byte item; int index = 0; +System.out.println("parseSqlInfo: first 2 bytes are " + isc_vax_integer(info, 0, 2) + " or: " + info[0] + ", " + info[1]); int i = 2; int len = isc_vax_integer(info, i, 2); i += 2; xsqlda.sqld = xsqlda.sqln = isc_vax_integer(info, i, len); +System.out.println("xsqlda.sqln read as " + xsqlda.sqln); i += len; xsqlda.sqlvar = new XSQLVAR[xsqlda.sqln]; @@ -1469,30 +1523,39 @@ case isc_info_sql_sqlda_seq: index = isc_vax_integer(info, i, len) - 1; xsqlda.sqlvar[index] = new XSQLVAR(); +System.out.println("new xsqlvar " + index); break; case isc_info_sql_type: xsqlda.sqlvar[index].sqltype = isc_vax_integer (info, i, len); +System.out.println("isc_info_sql_type " + xsqlda.sqlvar[index].sqltype); break; case isc_info_sql_sub_type: xsqlda.sqlvar[index].sqlsubtype = isc_vax_integer (info, i, len); +System.out.println("isc_info_sql_sub_type " + xsqlda.sqlvar[index].sqlsubtype); break; case isc_info_sql_scale: xsqlda.sqlvar[index].sqlscale = isc_vax_integer (info, i, len); +System.out.println("isc_info_sql_scale " + xsqlda.sqlvar[index].sqlscale); break; case isc_info_sql_length: xsqlda.sqlvar[index].sqllen = isc_vax_integer (info, i, len); +System.out.println("isc_info_sql_length " + xsqlda.sqlvar[index].sqllen); break; case isc_info_sql_field: xsqlda.sqlvar[index].sqlname = new String(info, i, len); +System.out.println("isc_info_sql_field " + xsqlda.sqlvar[index].sqlname); break; case isc_info_sql_relation: xsqlda.sqlvar[index].relname = new String(info, i, len); +System.out.println("isc_info_sql_relation " + xsqlda.sqlvar[index].relname); break; case isc_info_sql_owner: xsqlda.sqlvar[index].ownname = new String(info, i, len); +System.out.println("isc_info_sql_owner " + xsqlda.sqlvar[index].ownname); break; case isc_info_sql_alias: xsqlda.sqlvar[index].aliasname = new String(info, i, len); +System.out.println("isc_info_sql_alias " + xsqlda.sqlvar[index].aliasname); break; case isc_info_truncated: throw new GDSException(isc_dsql_sqlda_err); @@ -1502,8 +1565,27 @@ i += len; } } + return xsqlda; } + //DEBUG + private void checkAllRead(InputStream in) throws GDSException { + try { + int i = in.available(); + if (i > 0) { + System.out.println("Extra bytes in packet read: " + i); + byte[] b = new byte[i]; + in.read(b); + for (int j = 0; j < Math.min(b.length, 16); j++) { + System.out.println("byte: " + b[j]); + } + } + } + catch (IOException e) { + throw new GDSException("IOException in checkAllRead: " + e); + } + } + //inner classes @@ -1560,21 +1642,28 @@ } - public Clumplet newClumplet(int type, String content) { + public static Clumplet newClumplet(int type, String content) { return new ClumpletImpl(type, content.getBytes()); } - public Clumplet newClumplet(int type){ + public static Clumplet newClumplet(int type){ return new ClumpletImpl(type, new byte[] {}); } - public Clumplet newClumplet(int type, int c){ + public static Clumplet newClumplet(int type, int c){ return new ClumpletImpl(type, new byte[] {(byte)(c>>24), (byte)(c>>16), (byte)(c>>8), (byte)c}); } - public Clumplet newClumplet(int type, byte[] content) { + public static Clumplet newClumplet(int type, byte[] content) { return new ClumpletImpl(type, content); + } + + public static Clumplet cloneClumplet(Clumplet c) { + if (c == null) { + return null; + } + return new ClumpletImpl((ClumpletImpl)c); } private static class Response { Index: TestGds.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/TestGds.java,v retrieving revision 1.1 retrieving revision 1.2 diff -U3 -r1.1 -r1.2 --- TestGds.java 2001/05/25 16:18:06 1.1 +++ TestGds.java 2001/06/14 04:48:01 1.2 @@ -83,15 +83,22 @@ } public static Test suite() { +/* TestSuite suite= new TestSuite(); + suite.addTest( + new TestGds("testPreparedSelect") { + protected void runTest() throws Exception { super.testPreparedSelect(); } + } + ); + return suite;*/ return new TestSuite(TestGds.class); } public void setUp() { - gds = new org.firebirdsql.jgds.GDS_Impl(); - c = (ClumpletImpl)gds.newClumplet(gds.isc_dpb_num_buffers, new byte[] {90}); - c.append(gds.newClumplet(gds.isc_dpb_dummy_packet_interval, new byte[] {120, 10, 0, 0})); + gds = GDSFactory.newGDS(); + c = (ClumpletImpl)GDSFactory.newClumplet(gds.isc_dpb_num_buffers, new byte[] {90}); + c.append(GDSFactory.newClumplet(gds.isc_dpb_dummy_packet_interval, new byte[] {120, 10, 0, 0})); tpb.add(new Integer(gds.isc_tpb_write)); tpb.add(new Integer(gds.isc_tpb_read_committed)); tpb.add(new Integer(gds.isc_tpb_no_rec_version)); @@ -127,8 +134,8 @@ } private void doSQLImmed(isc_db_handle db, isc_tr_handle tr, String sql) throws Exception { - System.out.println("isc_dsql_exec_inmed2"); - gds.isc_dsql_exec_inmed2(db, tr, sql, + System.out.println("isc_dsql_exec_immed2"); + gds.isc_dsql_exec_immed2(db, tr, sql, GDS.SQL_DIALECT_CURRENT, null, null); } @@ -188,19 +195,6 @@ dropDatabase(db1); } - public void testCreateDropTable() throws Exception { - System.out.println(); - System.out.println("testCreateDropTable"); - db1 = createDatabase(dbName); - t1 = startTransaction(db1); - doSQLImmed(db1, t1, "create table r1 (col1 smallint not null primary key)"); - commit(t1); - t1 = startTransaction(db1); - doSQLImmed(db1, t1, "drop table r1"); - commit(t1); - dropDatabase(db1); - - } public void testDbHandleEquality() throws Exception { System.out.println(); @@ -269,4 +263,152 @@ dropDatabase(db1); // dropDatabase(db2); }*/ + + + private isc_db_handle setupTable() throws Exception { + isc_db_handle db = createDatabase(dbName); + t1 = startTransaction(db); + doSQLImmed(db, t1, "create table r1 (col1 smallint not null primary key, col2 smallint)"); + commit(t1); + return db; + } + + private void teardownTable(isc_db_handle db) throws Exception { + t1 = startTransaction(db); + doSQLImmed(db, t1, "drop table r1"); + commit(t1); + dropDatabase(db); + } + + public void testCreateDropTable() throws Exception { + System.out.println(); + System.out.println("testCreateDropTable"); + db1 = setupTable(); + teardownTable(db1); + } + + public void testInsert() throws Exception { + System.out.println(); + System.out.println("testInsert"); + db1 = setupTable(); + t1 = startTransaction(db1); + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (1, 2)"); + + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (2, 3)"); + + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (3, 4)"); + commit(t1); + + teardownTable(db1); + } + + + public void testParameterizedInsert() throws Exception { + System.out.println(); + System.out.println("testParameterizedInsert"); + db1 = setupTable(); + + t1 = startTransaction(db1); + XSQLDA xsqlda = new XSQLDA(2); + XSQLVAR xsqlvar = new XSQLVAR(); + xsqlvar.sqltype = GDS.SQL_SHORT; + xsqlvar.sqllen = 2; + xsqlvar.sqldata = new Short((short) 3); + xsqlda.sqlvar[0] = xsqlvar; + + xsqlvar = new XSQLVAR(); + xsqlvar.sqltype = GDS.SQL_SHORT; + xsqlvar.sqllen = 2; + xsqlvar.sqldata = new Short((short) 4); + xsqlda.sqlvar[1] = xsqlvar; + + System.out.println("isc_dsql_exec_immed2"); + gds.isc_dsql_exec_immed2(db1, t1, "INSERT INTO R1 VALUES (?, ?)", + GDS.SQL_DIALECT_CURRENT, xsqlda, null); + + + xsqlda = new XSQLDA(2); + xsqlvar = new XSQLVAR(); + xsqlvar.sqltype = GDS.SQL_SHORT; + xsqlvar.sqllen = 2; + xsqlvar.sqldata = null; + xsqlda.sqlvar[0] = xsqlvar; + + xsqlvar = new XSQLVAR(); + xsqlvar.sqltype = GDS.SQL_SHORT; + xsqlvar.sqllen = 2; + xsqlvar.sqldata = null; + xsqlda.sqlvar[1] = xsqlvar; + + System.out.println("isc_dsql_exec_immed2"); + gds.isc_dsql_exec_immed2(db1, t1, "SELECT COL1, COL2 FROM R1 WHERE COL1 = 3", + GDS.SQL_DIALECT_CURRENT, null, xsqlda); + + System.out.println("retrieved inserted row C1 = " + xsqlda.sqlvar[0].sqldata + " " + + "C2 = " + xsqlda.sqlvar[1].sqldata); + + + + commit(t1); + + teardownTable(db1); + } + + public void testPreparedSelect() throws Exception { + System.out.println(); + System.out.println("testPreparedSelect"); + db1 = setupTable(); + t1 = startTransaction(db1); + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (1, 2)"); + + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (2, 3)"); + + doSQLImmed(db1, t1, "INSERT INTO R1 VALUES (3, 4)"); + + XSQLDA in_xsqlda;// = new XSQLDA(); + XSQLDA out_xsqlda;// = new XSQLDA(); + + isc_stmt_handle stmt1 = gds.get_new_isc_stmt_handle(); + + System.out.println("isc_dsql_allocate_statement"); + gds.isc_dsql_allocate_statement(db1, stmt1); + + + System.out.println("isc_dsql_prepare"); + out_xsqlda = gds.isc_dsql_prepare(t1, stmt1, "SELECT COL1, COL2 FROM R1 WHERE COL1 = 1", + GDS.SQL_DIALECT_CURRENT);//, out_xsqlda); + +// System.out.println("isc_dsql_describe_bind"); +// in_xsqlda = gds.isc_dsql_describe_bind(stmt1, 1);//, in_xsqlda); + in_xsqlda = null; + +// in_xsqlda.sqlvar[0].sqldata = new Short((short) 1); + +// System.out.println("isc_dsql_describe"); +// out_xsqlda = gds.isc_dsql_describe(stmt1, 1);//, out_xsqlda); + + System.out.println("isc_dsql_execute2"); + gds.isc_dsql_execute2(t1, stmt1, 1, in_xsqlda, null); + +// System.out.println("isc_dsql_set_cursor_name"); +// gds.isc_dsql_set_cursor_name(stmt1, "cur1", 0); + +// int fetch_stat; + while (gds.isc_dsql_fetch(stmt1, 1, out_xsqlda) != null) { + for (int i = 0; i < out_xsqlda.sqld; i++) { + Short data = (Short) out_xsqlda.sqlvar[i].sqldata; + System.out.print(data.shortValue() + " "); + } + System.out.println(); + } + + System.out.println("isc_dsql_free_statement"); + gds.isc_dsql_free_statement(stmt1, GDS.DSQL_drop); + + commit(t1); + + teardownTable(db1); + } + + } Index: XdrInputStream.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/XdrInputStream.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- XdrInputStream.java 2001/05/25 16:18:06 1.2 +++ XdrInputStream.java 2001/06/14 04:48:01 1.3 @@ -69,7 +69,14 @@ public final byte[] readOpaque(int len) throws IOException { byte[] buffer = new byte[len]; - in.read(buffer); + int pos = 0; + int chunk; + while (pos < len) { + System.out.println("Available: " + in.available() + " trying to read to: " + len + " at: " + pos); + chunk = Math.min(in.available(), len - pos); + in.read(buffer, pos, chunk); + pos += chunk; + } for (int i = 0; i < ((4 - len) & 3); i++) { in.read(); } Index: Xdrable.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/Xdrable.java,v retrieving revision 1.1 retrieving revision 1.2 diff -U3 -r1.1 -r1.2 --- Xdrable.java 2001/05/25 16:18:06 1.1 +++ Xdrable.java 2001/06/14 04:48:01 1.2 @@ -40,8 +40,8 @@ interface Xdrable { int getLength(); - - void read(XdrInputStream in, int length) throws GDSException; + + void read(XdrInputStream in, int length) throws IOException; void write(XdrOutputStream out) throws IOException; Index: isc_stmt_handle_impl.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jgds/isc_stmt_handle_impl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -U3 -r1.1 -r1.2 --- isc_stmt_handle_impl.java 2001/05/24 16:03:44 1.1 +++ isc_stmt_handle_impl.java 2001/06/14 04:48:01 1.2 @@ -32,14 +32,33 @@ package org.firebirdsql.jgds; -import java.util.*; +import org.firebirdsql.gds.XSQLDA; +import java.util.List; +import java.util.LinkedList; + public class isc_stmt_handle_impl implements org.firebirdsql.gds.isc_stmt_handle { int rsr_id; isc_db_handle_impl rsr_rdb; - Vector rows = new Vector(); + XSQLDA in_sqlda = null; + XSQLDA out_sqlda = null; + List rows = new LinkedList(); + boolean allRowsFetched = false; public isc_stmt_handle_impl() { + } + + public XSQLDA getInSqlda() { + return in_sqlda; + } + + public XSQLDA getOutSqlda() { + return out_sqlda; + } + + public void clearRows() { + rows.clear(); + allRowsFetched = false; } } |
From: David J. <d_j...@us...> - 2001-06-14 04:48:05
|
Update of /cvsroot/firebird/client-java/src/resources In directory usw-pr-cvs1:/tmp/cvs-serv7418/resources Added Files: ra.xml Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- ra.xml ADDED --- |
From: David J. <d_j...@us...> - 2001-06-14 04:48:05
|
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc In directory usw-pr-cvs1:/tmp/cvs-serv7418/org/firebirdsql/jdbc Modified Files: FBCallableStatement.java FBConnection.java FBDataSource.java FBPreparedStatement.java FBResultSet.java FBResultSetMetaData.java FBRowSet.java FBRowSetMetaData.java FBStatement.java Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. Index: FBCallableStatement.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBCallableStatement.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBCallableStatement.java 2001/05/09 14:28:23 1.1.1.1 +++ FBCallableStatement.java 2001/06/14 04:48:01 1.2 @@ -37,8 +37,10 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; +import org.firebirdsql.jca.FBManagedConnection; + /** * * @see <related> @@ -82,6 +84,10 @@ * @see ResultSet */ public class FBCallableStatement extends FBPreparedStatement implements CallableStatement { + + FBCallableStatement(FBConnection c, String sql) throws SQLException { + super(c, sql); + } /** * Registers the OUT parameter in ordinal position Index: FBConnection.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBConnection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- FBConnection.java 2001/05/25 19:52:52 1.2 +++ FBConnection.java 2001/06/14 04:48:01 1.3 @@ -34,6 +34,9 @@ import java.sql.SQLWarning; import java.sql.Statement; +import javax.resource.cci.LocalTransaction; + +import org.firebirdsql.jca.FBLocalTransaction; import org.firebirdsql.jca.FBManagedConnection; //import javax.resource.cci.Connection;--can't import, two classes with same name. @@ -74,6 +77,8 @@ FBManagedConnection mc; + FBLocalTransaction localTransaction = null; + public FBConnection(FBManagedConnection mc) { this.mc = mc; } @@ -98,7 +103,7 @@ * @exception SQLException if a database access error occurs */ public Statement createStatement() throws SQLException { - return new FBStatement(mc); + return new FBStatement(this); } @@ -133,7 +138,7 @@ */ public PreparedStatement prepareStatement(String sql) throws SQLException { - return null; + return new FBPreparedStatement(this, sql); } @@ -261,7 +266,9 @@ * * @exception SQLException if a database access error occurs */ - public void close() throws SQLException { + public void close() { + mc.close(this); + mc = null; } @@ -271,8 +278,8 @@ * @return true if the connection is closed; false if it's still open * @exception SQLException if a database access error occurs */ - public boolean isClosed() throws SQLException { - throw new SQLException("Not yet implemented"); + public boolean isClosed() { + return mc == null; } @@ -540,6 +547,16 @@ * @see <a href="package-summary.html#2.0 API">What Is in the JDBC 2.0 API</a> */ public void setTypeMap(java.util.Map map) throws SQLException { + } + + //------------------------------------------- + //Borrowed from javax.resource.cci.Connection + + public FBLocalTransaction getLocalTransaction() { + if (localTransaction == null) { + localTransaction = new FBLocalTransaction(mc, this); + } + return localTransaction; } } Index: FBDataSource.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBDataSource.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBDataSource.java 2001/05/09 14:26:50 1.1.1.1 +++ FBDataSource.java 2001/06/14 04:48:01 1.2 @@ -26,10 +26,19 @@ // imports -------------------------------------- +import org.firebirdsql.jca.FBConnectionRequestInfo; +import org.firebirdsql.jca.FBManagedConnectionFactory; + +import java.io.PrintWriter; import java.io.Serializable; import java.sql.Connection; import javax.sql.DataSource; import java.sql.SQLException; +import javax.naming.Reference; +import javax.resource.Referenceable; +import javax.resource.ResourceException; +import javax.resource.spi.ConnectionManager; +import javax.resource.spi.ManagedConnectionFactory; /** @@ -50,8 +59,33 @@ */ -public class FBDataSource implements DataSource { +public class FBDataSource implements DataSource, Serializable, Referenceable { + + transient private ConnectionManager cm; + + transient private FBManagedConnectionFactory mcf; + + transient private PrintWriter log; + + private Reference jndiReference; + + private int loginTimeout = 0; + + public FBDataSource(FBManagedConnectionFactory mcf, ConnectionManager cm) { + this.mcf = mcf; + this.cm = cm; + } + + public void setReference(Reference ref) { + this.jndiReference = ref; + } + + public Reference getReference() { + return jndiReference; + } + + /** * <p>Attempt to establish a database connection. * @@ -59,7 +93,12 @@ * @exception SQLException if a database-access error occurs. */ public Connection getConnection() throws SQLException { - throw new SQLException("Not yet implemented"); + try { + return (Connection)cm.allocateConnection(mcf, mcf.getDefaultConnectionRequestInfo()); + } + catch (ResourceException re) { + throw new SQLException("Problem getting connection: " + re); + } } @@ -73,7 +112,15 @@ * @exception SQLException if a database-access error occurs. */ public Connection getConnection(String username, String password) throws SQLException { - throw new SQLException("Not yet implemented"); + try { + FBConnectionRequestInfo subjectCri = new FBConnectionRequestInfo(mcf.getDefaultConnectionRequestInfo()); + subjectCri.setUser(username); + subjectCri.setPassword(password); + return (Connection)cm.allocateConnection(mcf, subjectCri); + } + catch (ResourceException re) { + throw new SQLException("Problem getting connection: " + re); + } } @@ -94,7 +141,7 @@ * @exception SQLException if a database-access error occurs. */ public java.io.PrintWriter getLogWriter() throws SQLException { - throw new SQLException("Not yet implemented"); + return log; } @@ -115,7 +162,7 @@ * @exception SQLException if a database-access error occurs. */ public void setLogWriter(java.io.PrintWriter out) throws SQLException { - throw new SQLException("Not yet implemented"); + log = out; } @@ -131,7 +178,7 @@ * @exception SQLException if a database access error occurs. */ public void setLoginTimeout(int seconds) throws SQLException { - throw new SQLException("Not yet implemented"); + loginTimeout = seconds; } @@ -147,7 +194,7 @@ * @exception SQLException if a database access error occurs. */ public int getLoginTimeout() throws SQLException { - throw new SQLException("Not yet implemented"); + return loginTimeout; } Index: FBPreparedStatement.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBPreparedStatement.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBPreparedStatement.java 2001/05/09 14:28:08 1.1.1.1 +++ FBPreparedStatement.java 2001/06/14 04:48:01 1.2 @@ -26,6 +26,11 @@ // imports -------------------------------------- + +import org.firebirdsql.gds.GDS; +import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.XSQLVAR; +import org.firebirdsql.jca.FBManagedConnection; import java.math.BigDecimal; import java.util.Calendar; @@ -76,6 +81,20 @@ */ public class FBPreparedStatement extends FBStatement implements PreparedStatement { + + FBPreparedStatement(FBConnection c, String sql) throws SQLException { + super(c); + try { + if (fixedStmt == null) { + fixedStmt = mc.getAllocatedStatement(); + } + mc.prepareSQL(fixedStmt, sql, true); + } + catch (GDSException ge) { + throw new SQLException("GDS exception: " + ge.toString()); + } + + } /** * Executes the SQL query in this <code>PreparedStatement</code> object @@ -86,7 +105,10 @@ * @exception SQLException if a database access error occurs */ public ResultSet executeQuery() throws SQLException { - throw new SQLException("Not yet implemented"); + if (!execute()) { + throw new SQLException("No resultset for sql"); + } + return getResultSet(); } @@ -102,7 +124,10 @@ * @exception SQLException if a database access error occurs */ public int executeUpdate() throws SQLException { - throw new SQLException("Not yet implemented"); + if (execute()) { + throw new SQLException("update statement returned results!"); + } + return getUpdateCount(); } @@ -116,7 +141,8 @@ * @exception SQLException if a database access error occurs */ public void setNull(int parameterIndex, int sqlType) throws SQLException { - throw new SQLException("Not yet implemented"); + fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqlind = -1; + fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqldata = null; } @@ -130,7 +156,9 @@ * @exception SQLException if a database access error occurs */ public void setBoolean(int parameterIndex, boolean x) throws SQLException { - throw new SQLException("Not yet implemented"); + fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqlind = 0; + //not quite + fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqldata = new Boolean(x); } @@ -144,7 +172,8 @@ * @exception SQLException if a database access error occurs */ public void setByte(int parameterIndex, byte x) throws SQLException { - throw new SQLException("Not yet implemented"); + fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqlind = 0; +//not quite fixedStmt.getInSqlda().sqlvar[parameterIndex - 1].sqldata = x; } @@ -158,7 +187,12 @@ * @exception SQLException if a database access error occurs */ public void setShort(int parameterIndex, short x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_SHORT) { + throw new SQLException("Not a short, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = new Short(x); } @@ -172,7 +206,12 @@ * @exception SQLException if a database access error occurs */ public void setInt(int parameterIndex, int x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_LONG) { + throw new SQLException("Not an int, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = new Integer(x); } @@ -186,7 +225,12 @@ * @exception SQLException if a database access error occurs */ public void setLong(int parameterIndex, long x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_INT64) { + throw new SQLException("Not a long, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = new Long(x); } @@ -200,7 +244,12 @@ * @exception SQLException if a database access error occurs */ public void setFloat(int parameterIndex, float x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_FLOAT) { + throw new SQLException("Not a float field, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = new Float(x); } @@ -214,7 +263,12 @@ * @exception SQLException if a database access error occurs */ public void setDouble(int parameterIndex, double x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_DOUBLE) { + throw new SQLException("Not a double, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = new Double(x); } @@ -228,7 +282,13 @@ * @exception SQLException if a database access error occurs */ public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if ((sqlvar.sqltype & ~1) != GDS.SQL_INT64) { + throw new SQLException("Not a BigDecimal, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + //not quite + sqlvar.sqldata = x; } @@ -245,7 +305,12 @@ * @exception SQLException if a database access error occurs */ public void setString(int parameterIndex, String x) throws SQLException { - throw new SQLException("Not yet implemented"); + XSQLVAR sqlvar = fixedStmt.getInSqlda().sqlvar[parameterIndex - 1]; + if (((sqlvar.sqltype & ~1) != GDS.SQL_TEXT) && ((sqlvar.sqltype & ~1) != GDS.SQL_VARYING)){ + throw new SQLException("Not a String, type: " + sqlvar.sqltype); + } + sqlvar.sqlind = 0; + sqlvar.sqldata = x; } @@ -387,6 +452,9 @@ * @exception SQLException if a database access error occurs */ public void clearParameters() throws SQLException { + for (int i = 1; i <= fixedStmt.getInSqlda().sqln; i++) { + setNull(i, 0); + } } @@ -486,7 +554,14 @@ * @see Statement#execute */ public boolean execute() throws SQLException { - throw new SQLException("Not yet implemented"); + try { + closeResultSet(); + mc.executeStatement(fixedStmt); + return (fixedStmt.getOutSqlda().sqld > 0); + } + catch (GDSException ge) { + throw new SQLException("GDS exception: " + ge.toString()); + } } @@ -605,7 +680,7 @@ * 2.0 API</a> */ public ResultSetMetaData getMetaData() throws SQLException { - throw new SQLException("Not yet implemented"); + return new FBResultSetMetaData(fixedStmt); } @@ -709,6 +784,7 @@ * 2.0 API</a> */ public void setNull (int paramIndex, int sqlType, String typeName) throws SQLException { + setNull(paramIndex, sqlType); //all nulls are represented the same... a null reference } } Index: FBResultSet.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBResultSet.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBResultSet.java 2001/05/09 14:25:45 1.1.1.1 +++ FBResultSet.java 2001/06/14 04:48:01 1.2 @@ -39,7 +39,13 @@ import java.sql.SQLWarning; import java.sql.Statement; +import org.firebirdsql.gds.GDS; +import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.isc_stmt_handle; +import org.firebirdsql.gds.XSQLVAR; +import org.firebirdsql.jca.FBManagedConnection; + /** * * @see <related> @@ -230,6 +236,25 @@ */ public class FBResultSet implements ResultSet { + + private FBManagedConnection mc; + + private FBStatement fbstatement; + + private isc_stmt_handle stmt; + + private Object[] row = null; + + private int rowNum = 0; + + FBResultSet(FBManagedConnection mc, FBStatement fbstatement, isc_stmt_handle stmt) { + this.mc = mc; + this.fbstatement = fbstatement; + this.stmt = stmt; + mc.registerStatement(fbstatement); + } + + /** * Moves the cursor down one row from its current position. @@ -248,7 +273,13 @@ * @exception SQLException if a database access error occurs */ public boolean next() throws SQLException { - throw new SQLException("Not yet implemented"); + try { + row = mc.fetch(stmt); + return (row != null); + } + catch (GDSException ge) { + throw new SQLException("fetch problem: " + ge.toString()); + } } @@ -269,7 +300,7 @@ * @exception SQLException if a database access error occurs */ public void close() throws SQLException { - throw new SQLException("Not yet implemented"); + fbstatement.closeResultSet(); } @@ -305,7 +336,11 @@ * @exception SQLException if a database access error occurs */ public String getString(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if (((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_TEXT) + &&((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_VARYING)) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + return (String)row[columnIndex - 1]; } @@ -350,7 +385,13 @@ * @exception SQLException if a database access error occurs */ public short getShort(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_SHORT) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return 0; + } + return ((Short)row[columnIndex - 1]).shortValue(); } @@ -365,7 +406,13 @@ * @exception SQLException if a database access error occurs */ public int getInt(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_LONG) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return 0; + } + return ((Integer)row[columnIndex - 1]).intValue(); } @@ -380,7 +427,13 @@ * @exception SQLException if a database access error occurs */ public long getLong(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_INT64) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return 0; + } + return ((Long)row[columnIndex - 1]).longValue(); } @@ -395,7 +448,13 @@ * @exception SQLException if a database access error occurs */ public float getFloat(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_FLOAT) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return 0; + } + return ((Float)row[columnIndex - 1]).floatValue(); } @@ -410,14 +469,20 @@ * @exception SQLException if a database access error occurs */ public double getDouble(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_DOUBLE) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return 0; + } + return ((Double)row[columnIndex - 1]).doubleValue(); } /** * Gets the value of the designated column in the current row * of this <code>ResultSet</code> object as - * a <code>java.sql.BigDecimal</code> in the Java programming language. + * a <code>java.math.BigDecimal</code> in the Java programming language. * * @param columnIndex the first column is 1, the second is 2, ... * @param scale the number of digits to the right of the decimal point @@ -427,7 +492,14 @@ * @deprecated */ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_INT64) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return null; + } + //Is this the expected behavior???? Or do we move the decimal point? + return (BigDecimal.valueOf(((Long)row[columnIndex - 1]).longValue(), getXsqlvar(columnIndex).sqlscale)).setScale(scale); } @@ -594,7 +666,7 @@ * @exception SQLException if a database access error occurs */ public String getString(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getString(findColumn(columnName)); } @@ -609,7 +681,7 @@ * @exception SQLException if a database access error occurs */ public boolean getBoolean(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getBoolean(findColumn(columnName)); } @@ -624,7 +696,7 @@ * @exception SQLException if a database access error occurs */ public byte getByte(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getByte(findColumn(columnName)); } @@ -639,7 +711,7 @@ * @exception SQLException if a database access error occurs */ public short getShort(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getShort(findColumn(columnName)); } @@ -654,7 +726,7 @@ * @exception SQLException if a database access error occurs */ public int getInt(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getInt(findColumn(columnName)); } @@ -669,7 +741,7 @@ * @exception SQLException if a database access error occurs */ public long getLong(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getLong(findColumn(columnName)); } @@ -684,7 +756,7 @@ * @exception SQLException if a database access error occurs */ public float getFloat(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getFloat(findColumn(columnName)); } @@ -699,7 +771,7 @@ * @exception SQLException if a database access error occurs */ public double getDouble(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getDouble(findColumn(columnName)); } @@ -716,8 +788,8 @@ * @deprecated */ public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { - throw new SQLException("Not yet implemented"); - } + return getBigDecimal(findColumn(columnName), scale); + } /** @@ -732,7 +804,7 @@ * @exception SQLException if a database access error occurs */ public byte[] getBytes(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getBytes(findColumn(columnName)); } @@ -747,7 +819,7 @@ * @exception SQLException if a database access error occurs */ public java.sql.Date getDate(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getDate(findColumn(columnName)); } @@ -763,7 +835,7 @@ * @exception SQLException if a database access error occurs */ public java.sql.Time getTime(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getTime(findColumn(columnName)); } @@ -778,7 +850,7 @@ * @exception SQLException if a database access error occurs */ public java.sql.Timestamp getTimestamp(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getTimestamp(findColumn(columnName)); } @@ -805,7 +877,7 @@ * @exception SQLException if a database access error occurs */ public java.io.InputStream getAsciiStream(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getAsciiStream(findColumn(columnName)); } @@ -835,7 +907,7 @@ * @deprecated */ public java.io.InputStream getUnicodeStream(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getUnicodeStream(findColumn(columnName)); } @@ -861,7 +933,7 @@ * @exception SQLException if a database access error occurs */ public java.io.InputStream getBinaryStream(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getBinaryStream(findColumn(columnName)); } @@ -943,7 +1015,7 @@ * @exception SQLException if a database access error occurs */ public ResultSetMetaData getMetaData() throws SQLException { - throw new SQLException("Not yet implemented"); + return new FBResultSetMetaData(stmt); } @@ -973,7 +1045,10 @@ * @exception SQLException if a database access error occurs */ public Object getObject(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if (row == null) { + throw new SQLException("No row fetched"); + } + return row[columnIndex - 1]; } @@ -1003,7 +1078,7 @@ * @exception SQLException if a database access error occurs */ public Object getObject(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getObject(findColumn(columnName)); } @@ -1018,7 +1093,21 @@ * @exception SQLException if a database access error occurs */ public int findColumn(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + if (columnName == null || columnName.equals("")) { + throw new SQLException("zero length identifiers not allowed"); + } + XSQLVAR[] xsqlvars = stmt.getOutSqlda().sqlvar; + for (int i = 0; i< xsqlvars.length; i++) { + if (columnName.equals(xsqlvars[i].aliasname)) { + return ++i; + } + } + for (int i = 0; i< xsqlvars.length; i++) { + if (columnName.equals(xsqlvars[i].sqlname)) { + return ++i; + } + } + throw new SQLException("column name " + columnName + " not found in result set."); } @@ -1061,7 +1150,7 @@ * 2.0 API</a> */ public java.io.Reader getCharacterStream(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getCharacterStream(findColumn(columnName)); } @@ -1080,7 +1169,13 @@ * 2.0 API</a> */ public BigDecimal getBigDecimal(int columnIndex) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(columnIndex).sqltype & ~1) != GDS.SQL_INT64) { + throw new SQLException("Wrong type for column " + columnIndex + "type should be" + getXsqlvar(columnIndex).sqltype); + } + if (row[columnIndex - 1] == null) { + return null; + } + return BigDecimal.valueOf(((Long)row[columnIndex - 1]).longValue(), getXsqlvar(columnIndex).sqlscale); } @@ -1100,7 +1195,7 @@ * */ public BigDecimal getBigDecimal(String columnName) throws SQLException { - throw new SQLException("Not yet implemented"); + return getBigDecimal(findColumn(columnName)); } @@ -2617,7 +2712,7 @@ * This method uses the specified <code>Map</code> object for * custom mapping if appropriate. * - * @param colName the name of the column from which to retrieve the value + * @param columnName the name of the column from which to retrieve the value * @param map a <code>java.util.Map</code> object that contains the mapping * from SQL type names to classes in the Java programming language * @return an <code>Object</code> representing the SQL value in the specified column @@ -2625,8 +2720,8 @@ * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Object getObject(String colName, java.util.Map map) throws SQLException { - throw new SQLException("Not yet implemented"); + public Object getObject(String columnName, java.util.Map map) throws SQLException { + return getObject(findColumn(columnName), map); } @@ -2635,15 +2730,15 @@ * of this <code>ResultSet</code> object as a <code>Ref</code> object * in the Java programming language. * - * @param colName the column name + * @param columnName the column name * @return a <code>Ref</code> object representing the SQL <code>REF</code> value in * the specified column * @since 1.2 * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Ref getRef(String colName) throws SQLException { - throw new SQLException("Not yet implemented"); + public Ref getRef(String columnName) throws SQLException { + return getRef(findColumn(columnName)); } @@ -2652,15 +2747,15 @@ * of this <code>ResultSet</code> object as a <code>Blob</code> object * in the Java programming language. * - * @param colName the name of the column from which to retrieve the value + * @param columnName the name of the column from which to retrieve the value * @return a <code>Blob</code> object representing the SQL <code>BLOB</code> value in * the specified column * @since 1.2 * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Blob getBlob(String colName) throws SQLException { - throw new SQLException("Not yet implemented"); + public Blob getBlob(String columnName) throws SQLException { + return getBlob(findColumn(columnName)); } @@ -2669,15 +2764,15 @@ * of this <code>ResultSet</code> object as a <code>Clob</code> object * in the Java programming language. * - * @param colName the name of the column from which to retrieve the value + * @param columnName the name of the column from which to retrieve the value * @return a <code>Clob</code> object representing the SQL <code>CLOB</code> * value in the specified column * @since 1.2 * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Clob getClob(String colName) throws SQLException { - throw new SQLException("Not yet implemented"); + public Clob getClob(String columnName) throws SQLException { + return getClob(findColumn(columnName)); } @@ -2686,15 +2781,15 @@ * of this <code>ResultSet</code> object as an <code>Array</code> object * in the Java programming language. * - * @param colName the name of the column from which to retrieve the value + * @param columnName the name of the column from which to retrieve the value * @return an <code>Array</code> object representing the SQL <code>ARRAY</code> value in * the specified column * @since 1.2 * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Array getArray(String colName) throws SQLException { - throw new SQLException("Not yet implemented"); + public Array getArray(String columnName) throws SQLException { + return getArray(findColumn(columnName)); } @@ -2742,7 +2837,7 @@ * 2.0 API</a> */ public java.sql.Date getDate(String columnName, Calendar cal) throws SQLException { - throw new SQLException("Not yet implemented"); + return getDate(findColumn(columnName), cal); } @@ -2791,8 +2886,8 @@ * 2.0 API</a> */ public java.sql.Time getTime(String columnName, Calendar cal) throws SQLException { - throw new SQLException("Not yet implemented"); - } + return getTime(findColumn(columnName), cal); + } /** @@ -2839,8 +2934,20 @@ * 2.0 API</a> */ public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws SQLException { - throw new SQLException("Not yet implemented"); + return getTimestamp(findColumn(columnName), cal); + } + + //-------------------------------------------------------------------- + //package methods + + XSQLVAR getXsqlvar(int columnIndex) { + return stmt.getOutSqlda().sqlvar[columnIndex - 1]; + } + +/* int getColumnCount() { + return stmt.getOutSqlda().sqln; } +*/ } Index: FBResultSetMetaData.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBResultSetMetaData.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBResultSetMetaData.java 2001/05/09 14:24:47 1.1.1.1 +++ FBResultSetMetaData.java 2001/06/14 04:48:01 1.2 @@ -26,10 +26,20 @@ // imports -------------------------------------- +import org.firebirdsql.gds.GDS; +import org.firebirdsql.gds.isc_stmt_handle; +import org.firebirdsql.gds.XSQLDA; +import org.firebirdsql.gds.XSQLVAR; + +import java.math.BigDecimal; + import java.sql.ResultSetMetaData; +import java.sql.Blob; +import java.sql.Array; import java.sql.Connection; import java.sql.SQLException; +import java.sql.Types; /** * @@ -57,6 +67,12 @@ */ public class FBResultSetMetaData implements ResultSetMetaData { + + private isc_stmt_handle stmt; + + FBResultSetMetaData(isc_stmt_handle stmt) { + this.stmt = stmt; + } /** * Returns the number of columns in this <code>ResultSet</code> object. @@ -64,8 +80,8 @@ * @return the number of columns * @exception SQLException if a database access error occurs */ - public int getColumnCount() throws SQLException { - throw new SQLException("Not yet implemented"); + public int getColumnCount() { + return stmt.getOutSqlda().sqln;; } @@ -76,8 +92,8 @@ * @return <code>true</code> if so; <code>false</code> otherwise * @exception SQLException if a database access error occurs */ - public boolean isAutoIncrement(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + public boolean isAutoIncrement(int column) { + return false; } @@ -89,7 +105,7 @@ * @exception SQLException if a database access error occurs */ public boolean isCaseSensitive(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return true; } @@ -101,7 +117,13 @@ * @exception SQLException if a database access error occurs */ public boolean isSearchable(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + if (((getXsqlvar(column).sqltype & ~1) == GDS.SQL_ARRAY) + || ((getXsqlvar(column).sqltype & ~1) == GDS.SQL_BLOB)) { + return false; + } + else { + return true; + } } @@ -113,7 +135,7 @@ * @exception SQLException if a database access error occurs */ public boolean isCurrency(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return false; } @@ -126,7 +148,12 @@ * @exception SQLException if a database access error occurs */ public int isNullable(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + if ((getXsqlvar(column).sqltype & 1) == 1) { + return columnNullable; + } + else { + return columnNoNulls; + } } @@ -156,7 +183,17 @@ * @exception SQLException if a database access error occurs */ public boolean isSigned(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + switch (getXsqlvar(column).sqltype & ~1) { + case GDS.SQL_SHORT: + case GDS.SQL_LONG: + case GDS.SQL_FLOAT: + case GDS.SQL_DOUBLE: + case GDS.SQL_D_FLOAT: + case GDS.SQL_INT64: + return true; + default: + return false; + } } @@ -169,7 +206,44 @@ * @exception SQLException if a database access error occurs */ public int getColumnDisplaySize(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + //These are mostly wrong!! + switch (getXsqlvar(column).sqltype & ~1) { + case GDS.SQL_TEXT: + return getXsqlvar(column).sqllen; + case GDS.SQL_VARYING: + return getXsqlvar(column).sqllen; + case GDS.SQL_SHORT: + return getXsqlvar(column).sqllen; + case GDS.SQL_LONG: + return getXsqlvar(column).sqllen; + case GDS.SQL_FLOAT: + return getXsqlvar(column).sqllen; + case GDS.SQL_DOUBLE: + return getXsqlvar(column).sqllen; + case GDS.SQL_D_FLOAT: + return getXsqlvar(column).sqllen; + case GDS.SQL_TIMESTAMP: + return getXsqlvar(column).sqllen; + case GDS.SQL_BLOB: + return 0; + case GDS.SQL_ARRAY: + return 0; + case GDS.SQL_QUAD: + return getXsqlvar(column).sqllen; + case GDS.SQL_TYPE_TIME: + return getXsqlvar(column).sqllen; + case GDS.SQL_TYPE_DATE: + return 10; + case GDS.SQL_INT64: + if (getXsqlvar(column).sqlscale == 0) { + return getXsqlvar(column).sqllen; + } + else { + return getXsqlvar(column).sqllen; + } + default: + throw new SQLException("Unkown sql type"); + } } @@ -182,7 +256,7 @@ * @exception SQLException if a database access error occurs */ public String getColumnLabel(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return (getXsqlvar(column).aliasname == null) ? getXsqlvar(column).sqlname: getXsqlvar(column).aliasname; } @@ -194,7 +268,7 @@ * @exception SQLException if a database access error occurs */ public String getColumnName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return getXsqlvar(column).sqlname; } @@ -206,7 +280,9 @@ * @exception SQLException if a database access error occurs */ public String getSchemaName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + //not really implemented + throw new SQLException("Schemas aren't supported"); + //return getXsqlvar(column).ownname; } @@ -218,7 +294,8 @@ * @exception SQLException if a database access error occurs */ public int getPrecision(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + //presumable wrong!! + return getXsqlvar(column).sqllen; } @@ -230,7 +307,7 @@ * @exception SQLException if a database access error occurs */ public int getScale(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return getXsqlvar(column).sqlscale; } @@ -242,7 +319,7 @@ * @exception SQLException if a database access error occurs */ public String getTableName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + return getXsqlvar(column).relname; } @@ -254,7 +331,7 @@ * @exception SQLException if a database access error occurs */ public String getCatalogName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + throw new SQLException("Catalogs not supported"); } @@ -267,7 +344,43 @@ * @see Types */ public int getColumnType(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + switch (getXsqlvar(column).sqltype & ~1) { + case GDS.SQL_TEXT: + return Types.CHAR; + case GDS.SQL_VARYING: + return Types.VARCHAR; + case GDS.SQL_SHORT: + return Types.SMALLINT; + case GDS.SQL_LONG: + return Types.BIGINT; + case GDS.SQL_FLOAT: + return Types.FLOAT; + case GDS.SQL_DOUBLE: + return Types.DOUBLE; + case GDS.SQL_D_FLOAT: + return Types.DOUBLE; + case GDS.SQL_TIMESTAMP: + return Types.TIMESTAMP; + case GDS.SQL_BLOB: + return Types.BLOB; + case GDS.SQL_ARRAY: + return Types.ARRAY; + case GDS.SQL_QUAD: + return Types.BIGINT; + case GDS.SQL_TYPE_TIME: + return Types.TIME; + case GDS.SQL_TYPE_DATE: + return Types.DATE; + case GDS.SQL_INT64: + if (getXsqlvar(column).sqlscale == 0) { + return Types.BIGINT; + } + else { + return Types.DECIMAL; + } + default: + throw new SQLException("Unkown sql type"); + } } @@ -280,7 +393,39 @@ * @exception SQLException if a database access error occurs */ public String getColumnTypeName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + //Maybe these are supposed to be the sql keywords???? + switch (getXsqlvar(column).sqltype & ~1) { + case GDS.SQL_TEXT: + return "SQL_TEXT"; + case GDS.SQL_VARYING: + return "SQL_VARYING"; + case GDS.SQL_SHORT: + return "SQL_SHORT"; + case GDS.SQL_LONG: + return "SQL_LONG"; + case GDS.SQL_FLOAT: + return "SQL_FLOAT"; + case GDS.SQL_DOUBLE: + return "SQL_DOUBLE"; + case GDS.SQL_D_FLOAT: + return "SQL_D_FLOAT"; + case GDS.SQL_TIMESTAMP: + return "SQL_TIMESTAMP"; + case GDS.SQL_BLOB: + return "SQL_BLOB"; + case GDS.SQL_ARRAY: + return "SQL_ARRAY"; + case GDS.SQL_QUAD: + return "SQL_QUAD"; + case GDS.SQL_TYPE_TIME: + return "SQL_TYPE_TIME"; + case GDS.SQL_TYPE_DATE: + return "SQL_TYPE_DATE"; + case GDS.SQL_INT64: + return "SQL_INT64"; + default: + throw new SQLException("Unkown sql type"); + } } @@ -292,6 +437,7 @@ * @exception SQLException if a database access error occurs */ public boolean isReadOnly(int column) throws SQLException { + //Need to consider priveleges!! throw new SQLException("Not yet implemented"); } @@ -304,6 +450,7 @@ * @exception SQLException if a database access error occurs */ public boolean isWritable(int column) throws SQLException { + //Needs priveleges??? throw new SQLException("Not yet implemented"); } @@ -316,6 +463,7 @@ * @exception SQLException if a database access error occurs */ public boolean isDefinitelyWritable(int column) throws SQLException { + //Need to consider privileges!!! throw new SQLException("Not yet implemented"); } @@ -339,7 +487,51 @@ * 2.0 API</a> */ public String getColumnClassName(int column) throws SQLException { - throw new SQLException("Not yet implemented"); + switch (getXsqlvar(column).sqltype & ~1) { + case GDS.SQL_TEXT: + return String.class.getName(); + case GDS.SQL_VARYING: + return String.class.getName(); + case GDS.SQL_SHORT: + return Short.class.getName(); + case GDS.SQL_LONG: + return Long.class.getName(); + case GDS.SQL_FLOAT: + return Float.class.getName(); + case GDS.SQL_DOUBLE: + return Double.class.getName(); + case GDS.SQL_D_FLOAT: + return Double.class.getName(); + case GDS.SQL_TIMESTAMP: + return java.sql.Timestamp.class.getName(); + case GDS.SQL_BLOB: + return Blob.class.getName(); + case GDS.SQL_ARRAY: + return Array.class.getName(); + case GDS.SQL_QUAD: + return Long.class.getName(); + case GDS.SQL_TYPE_TIME: + return java.sql.Time.class.getName(); + case GDS.SQL_TYPE_DATE: + return java.sql.Date.class.getName(); + case GDS.SQL_INT64: + if (getXsqlvar(column).sqlscale == 0) { + return Long.class.getName(); + } + else { + return BigDecimal.class.getName(); + } + default: + throw new SQLException("Unkown sql type"); + } + } + + + //private methods + + private XSQLVAR getXsqlvar(int columnIndex) { + return stmt.getOutSqlda().sqlvar[columnIndex - 1]; } + } Index: FBRowSet.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBRowSet.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBRowSet.java 2001/05/09 14:26:08 1.1.1.1 +++ FBRowSet.java 2001/06/14 04:48:01 1.2 @@ -26,6 +26,9 @@ // imports -------------------------------------- +import org.firebirdsql.jca.FBManagedConnection; +import org.firebirdsql.gds.isc_stmt_handle; + import javax.sql.RowSet; import javax.sql.RowSetListener; @@ -76,6 +79,11 @@ */ public class FBRowSet extends FBResultSet implements RowSet { + + FBRowSet(FBManagedConnection mc, FBStatement fbstatement, isc_stmt_handle stmt) { + super(mc, fbstatement, stmt); + } + //----------------------------------------------------------------------- // Properties Index: FBRowSetMetaData.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBRowSetMetaData.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBRowSetMetaData.java 2001/05/09 14:26:13 1.1.1.1 +++ FBRowSetMetaData.java 2001/06/14 04:48:01 1.2 @@ -26,9 +26,12 @@ // imports -------------------------------------- + import javax.sql.RowSetMetaData; import java.sql.SQLException; +import java.sql.*; +import org.firebirdsql.gds.isc_stmt_handle; /** * @@ -38,7 +41,6 @@ */ -import java.sql.*; /** * <P>The RowSetMetaData interface extends ResultSetMetaData with @@ -48,6 +50,10 @@ */ public class FBRowSetMetaData extends FBResultSetMetaData implements RowSetMetaData { + + FBRowSetMetaData(isc_stmt_handle stmt) { + super(stmt); + } /** * Set the number of columns in the RowSet. Index: FBStatement.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jdbc/FBStatement.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- FBStatement.java 2001/05/25 19:52:52 1.2 +++ FBStatement.java 2001/06/14 04:48:01 1.3 @@ -34,6 +34,7 @@ import org.firebirdsql.jca.FBManagedConnection; import org.firebirdsql.gds.GDSException; +import org.firebirdsql.gds.isc_stmt_handle; /** * @@ -60,10 +61,16 @@ */ public class FBStatement implements Statement { - private FBManagedConnection mc; + private FBConnection c; + protected FBManagedConnection mc; - FBStatement(FBManagedConnection mc) { - this.mc = mc; + protected isc_stmt_handle fixedStmt = null; + + private FBResultSet currentRs = null; + + FBStatement(FBConnection c) { + this.c = c; + mc = c.mc; } /** @@ -75,7 +82,10 @@ * @exception SQLException if a database access error occurs */ public ResultSet executeQuery(String sql) throws SQLException { - throw new SQLException("Not yet implemented"); + if (!execute(sql)) { + throw new SQLException("query did not return a result set: " + sql); + } + return getResultSet(); } @@ -92,7 +102,10 @@ * @exception SQLException if a database access error occurs */ public int executeUpdate(String sql) throws SQLException { - throw new SQLException("Not yet implemented"); + if (execute(sql)) { + throw new SQLException("update statement returned results!"); + } + return getUpdateCount(); } @@ -110,7 +123,18 @@ * @exception SQLException if a database access error occurs */ public void close() throws SQLException { - throw new SQLException("Not yet implemented"); + if (fixedStmt != null) { + try { + mc.closeStatement(fixedStmt, true); + } + catch (GDSException ge) { + throw new SQLException("could not close statement: " + ge.toString()); + } + finally { + fixedStmt = null; + currentRs = null; + } + } } @@ -324,7 +348,13 @@ */ public boolean execute(String sql) throws SQLException { try { - return mc.executeSQL(sql); + closeResultSet(); + if (fixedStmt == null) { + fixedStmt = mc.getAllocatedStatement(); + } + mc.prepareSQL(fixedStmt, sql, false); + mc.executeStatement(fixedStmt); + return (fixedStmt.getOutSqlda().sqld > 0); } catch (GDSException ge) { throw new SQLException("GDS exception: " + ge.toString()); @@ -342,7 +372,14 @@ * @see #execute */ public ResultSet getResultSet() throws SQLException { - throw new SQLException("Not yet implemented"); + if (currentRs != null) { + throw new SQLException("Only one resultset at a time/statement!"); + } + if (fixedStmt == null) { + throw new SQLException("No statement just executed"); + } + currentRs = new FBResultSet(mc, this, fixedStmt); + return currentRs; } @@ -357,7 +394,19 @@ * @see #execute */ public int getUpdateCount() throws SQLException { - throw new SQLException("Not yet implemented"); + try { + FBManagedConnection.SqlInfo i = mc.getSqlInfo(fixedStmt); +System.out.println("InsertCount: " + i.getInsertCount()); +System.out.println("UpdateCount: " + i.getUpdateCount()); +System.out.println("DeleteCount: " + i.getDeleteCount()); + +System.out.println("returning: " + Math.max(i.getInsertCount(), Math.max(i.getUpdateCount(), i.getDeleteCount()))); + + return Math.max(i.getInsertCount(), Math.max(i.getUpdateCount(), i.getDeleteCount())); + } + catch (GDSException ge) { + throw new SQLException("Could not get UpdateCount: " + ge); + } } @@ -595,8 +644,29 @@ * @see <a href="package-summary.html#2.0 API">What Is in the JDBC * 2.0 API</a> */ - public Connection getConnection() throws SQLException { - throw new SQLException("Not yet implemented"); + public Connection getConnection() { + return c; + } + + //package level + + void closeResultSet() throws SQLException { + if (currentRs != null) { + try { + mc.closeStatement(fixedStmt, false); + } + catch (GDSException ge) { + throw new SQLException("problem closing resultset: " + ge); + } + currentRs = null; + } + } + + public void forgetResultSet() { //yuck should be package + currentRs = null; + if (fixedStmt != null) { + fixedStmt.clearRows(); + } } } |
From: David J. <d_j...@us...> - 2001-06-14 04:48:04
|
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/jca In directory usw-pr-cvs1:/tmp/cvs-serv7418/org/firebirdsql/jca Modified Files: FBConnectionRequestInfo.java FBLocalTransaction.java FBManagedConnection.java FBManagedConnectionFactory.java FBStandAloneConnectionManager.java TestFBManagedConnectionFactory.java Added Files: TestFBConnection.java TestFBResultSet.java TestFBStandAloneConnectionManager.java TestFBXAResource.java TestXABase.java Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- TestFBConnection.java ADDED --- --- TestFBResultSet.java ADDED --- --- TestFBStandAloneConnectionManager.java ADDED --- --- TestFBXAResource.java ADDED --- --- TestXABase.java ADDED --- Index: FBConnectionRequestInfo.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/FBConnectionRequestInfo.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBConnectionRequestInfo.java 2001/05/09 14:28:33 1.1.1.1 +++ FBConnectionRequestInfo.java 2001/06/14 04:48:01 1.2 @@ -30,7 +30,11 @@ import javax.resource.ResourceException; +import org.firebirdsql.gds.Clumplet; +import org.firebirdsql.gds.GDS; +import org.firebirdsql.gds.GDSFactory; + /** * * @see <related> @@ -53,6 +57,52 @@ **/ public class FBConnectionRequestInfo implements ConnectionRequestInfo { + + private Clumplet c = null; + + public FBConnectionRequestInfo() { + } + + public FBConnectionRequestInfo(FBConnectionRequestInfo src) { + c = GDSFactory.cloneClumplet(src.c); + } + + Clumplet getDpb() { + return c; + } + + public void setProperty(int type, String content) { + append(GDSFactory.newClumplet(type, content)); + } + + public void setProperty(int type) { + append(GDSFactory.newClumplet(type)); + } + + public void setProperty(int type, int content) { + append(GDSFactory.newClumplet(type, content)); + } + + public void setProperty(int type, byte[] content) { + append(GDSFactory.newClumplet(type, content)); + } + + private void append(Clumplet newc) { + if (c == null) { + c = newc; + } + else { + c.append(newc); + } + } + + public void setUser(String user) { + setProperty(GDS.isc_dpb_user_name, user); + } + + public void setPassword(String password) { + setProperty(GDS.isc_dpb_password, password); + } /** Checks whether this instance is equal to another. Since connectionRequestInfo is defined @@ -65,8 +115,15 @@ **/ - public boolean equals(java.lang.Object other) { - return false;//not yet implemented + public boolean equals(Object other) { + if ((other == null) || !(other instanceof FBConnectionRequestInfo)) { + return false; + } + Clumplet otherc = ((FBConnectionRequestInfo)other).c; + if (c == null) { + return (otherc == null); + } + return c.equals(otherc); } /** @@ -78,7 +135,10 @@ **/ public int hashCode() { - return 0;//not yet implemented; + if (c == null) { + return 0; + } + return c.hashCode(); } } Index: FBLocalTransaction.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/FBLocalTransaction.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBLocalTransaction.java 2001/05/09 14:28:29 1.1.1.1 +++ FBLocalTransaction.java 2001/06/14 04:48:01 1.2 @@ -27,19 +27,41 @@ // imports -------------------------------------- +import javax.resource.spi.ConnectionEvent; import javax.resource.spi.LocalTransaction; import javax.resource.ResourceException; +import javax.transaction.xa.XAException; +import javax.transaction.xa.XAResource; +import javax.transaction.xa.Xid; +import org.firebirdsql.jdbc.FBConnection; + + /** * * @see <related> * @author David Jencks (dav...@ea...) * @version $ $ */ + + public class FBLocalTransaction implements LocalTransaction, javax.resource.cci.LocalTransaction { + + private FBManagedConnection mc; + + private Xid xid = null; - public class FBLocalTransaction implements LocalTransaction { + //used to determine if local transaction events notify ConnectionEventListeners + //see jca spec section 6.8. Basically not null means this is cci LocalTransaction, + //null means spi.LocalTransaction. + private FBConnection c = null; + + //should be package!!! perhaps reorganize and eliminate jdbc!!! + public FBLocalTransaction(FBManagedConnection mc, FBConnection c) { + this.mc = mc; + this.c = c; + } @@ -52,7 +74,19 @@ EISSystemException - EIS instance specific error condition **/ public void begin() throws ResourceException { - throw new ResourceException("Not yet implemented"); + if (xid != null) { + throw new ResourceException("local transaction active: can't begin another"); + } + xid = new FBLocalXid(); + try { + mc.start(xid, XAResource.TMNOFLAGS); //FBManagedConnection is its own XAResource + } + catch (XAException e) { + throw new ResourceException("couldn't start local transaction: " + e); + } + if (c != null) { + mc.notify(ConnectionEvent.LOCAL_TRANSACTION_STARTED, c, null); + } } @@ -65,7 +99,22 @@ EISSystemException - EIS instance specific error condition **/ public void commit() throws ResourceException { - throw new ResourceException("Not yet implemented"); + if (xid == null) { + throw new ResourceException("no local transaction active: can't commit"); + } + try { + mc.end(xid, XAResource.TMNOFLAGS); //FBManagedConnection is its own XAResource + mc.commit(xid, true); + } + catch (XAException e) { + throw new ResourceException("couldn't commit local transaction: " + e); + } + finally { + xid = null; + } + if (c != null) { + mc.notify(ConnectionEvent.LOCAL_TRANSACTION_COMMITTED, c, null); + } } @@ -81,7 +130,60 @@ **/ public void rollback() throws ResourceException { - throw new ResourceException("Not yet implemented"); + if (xid == null) { + throw new ResourceException("no local transaction active: can't rollback"); + } + try { + mc.end(xid, XAResource.TMNOFLAGS); //??? on flags --FBManagedConnection is its own XAResource + mc.rollback(xid); + } + catch (XAException e) { + throw new ResourceException("couldn't commit local transaction: " + e); + } + finally { + xid = null; + } + if (c != null) { + mc.notify(ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK, c, null); + } } + + + //This is an intentionally non-implemented xid, so if prepare is called with it, it won't work. + //Only object identity works for equals! + static class FBLocalXid implements Xid { + + private static final int formatId = 0x0102;//???????????? + + public FBLocalXid() { + } + + /** + * Return the global transaction id of this transaction. + */ + public byte[] getGlobalTransactionId() + { + return null; + } + + /** + * Return the branch qualifier of this transaction. + */ + public byte[] getBranchQualifier() + { + return null; + } + + /** + * Return the format identifier of this transaction. + * + * The format identifier augments the global id and specifies + * how the global id and branch qualifier should be interpreted. + */ + public int getFormatId() { + return formatId; + } + } + } Index: FBManagedConnection.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/FBManagedConnection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -U3 -r1.3 -r1.4 --- FBManagedConnection.java 2001/05/25 19:58:17 1.3 +++ FBManagedConnection.java 2001/06/14 04:48:01 1.4 @@ -31,10 +31,13 @@ import javax.resource.spi.ManagedConnection; import javax.resource.spi.ManagedConnectionMetaData; import javax.resource.spi.LocalTransaction; +import javax.resource.spi.ConnectionEvent; import javax.resource.spi.ConnectionEventListener; import javax.resource.spi.ConnectionRequestInfo; +import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Iterator; import javax.transaction.xa.XAException; import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; @@ -42,12 +45,14 @@ import javax.security.auth.Subject; import org.firebirdsql.gds.isc_db_handle; +import org.firebirdsql.gds.isc_stmt_handle; import org.firebirdsql.gds.isc_tr_handle; import org.firebirdsql.gds.GDS; import org.firebirdsql.gds.GDSException; import org.firebirdsql.gds.XSQLDA; import org.firebirdsql.gds.XSQLVAR; import org.firebirdsql.jdbc.FBConnection; +import org.firebirdsql.jdbc.FBStatement; /** * @@ -70,18 +75,26 @@ private ArrayList connectionEventListeners = new ArrayList(); + private ArrayList connectionHandles = new ArrayList(); + + private PrintWriter log; + private int timeout = 0; private Subject s; + private FBConnectionRequestInfo cri; + private isc_tr_handle currentTr; private isc_db_handle currentDbHandle; - FBManagedConnection(Subject s, FBManagedConnectionFactory mcf) { + FBManagedConnection(Subject s, FBConnectionRequestInfo cri, FBManagedConnectionFactory mcf) { this.mcf = mcf; this.s = s; + this.cri = cri; + this.log = mcf.getLogWriter(); } @@ -140,8 +153,8 @@ ResourceException - generic exception if operation fails ResourceAdapterInternalException - resource adapter related error condition **/ - public void setLogWriter(java.io.PrintWriter out) throws ResourceException { - throw new ResourceException("not yet implemented"); + public void setLogWriter(PrintWriter out){ + this.log = out; } @@ -163,8 +176,8 @@ ResourceException - generic exception if operation fails **/ - public java.io.PrintWriter getLogWriter() throws ResourceException { - throw new ResourceException("not yet implemented"); + public PrintWriter getLogWriter() { + return log; } /**<P> Add an event listener. @@ -200,6 +213,7 @@ public void associateConnection(java.lang.Object connection) throws ResourceException { try { ((FBConnection)connection).setManagedConnection(this); + connectionHandles.add(connection); } catch (ClassCastException cce) { throw new ResourceException("invalid connection supplied to associateConnection: " + cce); @@ -234,7 +248,9 @@ localtransaction is in progress that doesn't allow connection cleanup */ public void cleanup() throws ResourceException { - throw new ResourceException("not yet implemented"); + for (int i = connectionHandles.size() - 1; i>= 0; i--) { + ((FBConnection)connectionHandles.get(i)).close(); + } } /** @@ -267,8 +283,9 @@ throws ResourceException { //subject currently ignored //cxRequestInfo currently ignored. - - return new FBConnection(this); + FBConnection c = new FBConnection(this); + connectionHandles.add(c); + return c; } @@ -286,7 +303,20 @@ IllegalStateException - illegal state for destroying connection **/ public void destroy() throws ResourceException { - throw new ResourceException("not yet implemented"); + if (currentTr != null) { + throw new IllegalStateException("Can't destroy managed connection with active transaction"); + } + if (currentDbHandle != null) { + try { + mcf.gds.isc_detach_database(currentDbHandle); + } + catch (GDSException ge) { + throw new ResourceException("Can't detach from db: " + ge.toString()); + } + finally { + currentDbHandle = null; + } + } } @@ -444,16 +474,65 @@ } //FB public methods. Could be package if packages reorganized. + + public isc_stmt_handle getAllocatedStatement() throws GDSException { + //Should we test for dbhandle? + if (currentTr == null) { + throw new GDSException("No transaction started for allocate statement"); + } + isc_stmt_handle stmt = mcf.gds.get_new_isc_stmt_handle(); + mcf.gds.isc_dsql_allocate_statement(currentTr.getDbHandle(), stmt); + return stmt; + } - public boolean executeSQL(String sql) throws GDSException { + public void prepareSQL(isc_stmt_handle stmt, String sql, boolean describeBind) throws GDSException { //Should we test for dbhandle? - XSQLDA out = new XSQLDA(); - mcf.gds.isc_dsql_exec_inmed2(currentTr.getDbHandle(), currentTr, sql, - GDS.SQL_DIALECT_CURRENT, null, out); + XSQLDA out = mcf.gds.isc_dsql_prepare(currentTr, stmt, sql, GDS.SQL_DIALECT_CURRENT); + if (out.sqld != out.sqln) { + throw new GDSException("Not all columns returned"); + } + if (describeBind) { + mcf.gds.isc_dsql_describe_bind(stmt, GDS.SQLDA_VERSION1); + } + } + + public void executeStatement(isc_stmt_handle stmt) throws GDSException { + mcf.gds.isc_dsql_execute2(currentTr, stmt, + GDS.SQLDA_VERSION1, stmt.getInSqlda(), null); - return false;//Hah! } - + + public Object[] fetch(isc_stmt_handle stmt) throws GDSException { + return mcf.gds.isc_dsql_fetch(stmt, GDS.SQLDA_VERSION1, stmt.getOutSqlda()); + } + + public void closeStatement(isc_stmt_handle stmt, boolean deallocate) throws GDSException { + mcf.gds.isc_dsql_free_statement(stmt, (deallocate) ? GDS.DSQL_drop: GDS.DSQL_close); + } + + public void close(FBConnection c) { + notify(ConnectionEvent.CONNECTION_CLOSED, c, null); + connectionHandles.remove(c); + } + + public void registerStatement(FBStatement fbStatement) { + if (currentTr == null) { + throw new Error("registerStatement called with no transaction"); + } + + mcf.registerStatementWithTransaction(currentTr, fbStatement); + } + + private static byte[] stmtInfo = new byte[] + {GDS.isc_info_sql_records, + GDS.isc_info_sql_stmt_type, + GDS.isc_info_end}; + private static int INFO_SIZE = 128; + + public SqlInfo getSqlInfo(isc_stmt_handle stmt) throws GDSException { + return new SqlInfo(mcf.gds.isc_dsql_sql_info(stmt, stmtInfo.length, stmtInfo, INFO_SIZE), mcf.gds); + } + //-------------------------------------------------------------------- //package visibility //-------------------------------------------------------------------- @@ -465,15 +544,121 @@ currentDbHandle = currentTr.getDbHandle(); } } - //temporarily public for testing - public isc_db_handle getIscDBHandle() throws XAException { + + isc_db_handle getIscDBHandle() throws XAException { if (currentDbHandle == null) { - currentDbHandle = mcf.getDbHandle(); + currentDbHandle = mcf.getDbHandle(cri); } return currentDbHandle; } - - + void notify(int type, FBConnection c, Exception e) { + ConnectionEvent ce = new ConnectionEvent(this, type, e); + ce.setConnectionHandle(c); + Iterator i = connectionEventListeners.iterator(); + switch (type) { + case ConnectionEvent.CONNECTION_CLOSED: + while (i.hasNext()) { + ((ConnectionEventListener)i.next()).connectionClosed(ce); + } + case ConnectionEvent.CONNECTION_ERROR_OCCURRED: + while (i.hasNext()) { + ((ConnectionEventListener)i.next()).connectionErrorOccurred(ce); + } + case ConnectionEvent.LOCAL_TRANSACTION_STARTED: + while (i.hasNext()) { + ((ConnectionEventListener)i.next()).localTransactionStarted(ce); + } + case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED: + while (i.hasNext()) { + ((ConnectionEventListener)i.next()).localTransactionCommitted(ce); + } + case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK: + while (i.hasNext()) { + ((ConnectionEventListener)i.next()).localTransactionRolledback(ce); + } + + default: +// throw new + } + } + + //----------------------------------------- + //Private methods + //----------------------------------------- + + public static class SqlInfo { + private int statementType; + private int insertCount; + private int updateCount; + private int deleteCount; + private int selectCount; //???? + + SqlInfo(byte[] buffer, GDS gds) { + int pos = 0; + int length; + int type; + while ((type = buffer[pos++]) != GDS.isc_info_end) { + length = gds.isc_vax_integer(buffer, pos, 2); + pos += 2; + switch (type) { + case GDS.isc_info_sql_records: + int l; + int t; + while ((t = buffer[pos++]) != GDS.isc_info_end) { + l = gds.isc_vax_integer(buffer, pos, 2); + pos += 2; + switch (t) { + case GDS.isc_info_req_insert_count: + insertCount = gds.isc_vax_integer(buffer, pos, l); + break; + case GDS.isc_info_req_update_count: + updateCount = gds.isc_vax_integer(buffer, pos, l); + break; + case GDS.isc_info_req_delete_count: + deleteCount = gds.isc_vax_integer(buffer, pos, l); + break; + case GDS.isc_info_req_select_count: + selectCount = gds.isc_vax_integer(buffer, pos, l); + break; + default: + break; + } + pos += l; + } + break; + case GDS.isc_info_sql_stmt_type: + statementType = gds.isc_vax_integer(buffer, pos, length); + pos += length; + break; + default: + pos += length; + break; + } + } + } + + public int getStatementType() { + return statementType; + } + + public int getInsertCount() { + return insertCount; + } + + public int getUpdateCount() { + return updateCount; + } + + public int getDeleteCount() { + return deleteCount; + } + + public int getSelectCount() { + return selectCount; + } + } + + } Index: FBManagedConnectionFactory.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/FBManagedConnectionFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- FBManagedConnectionFactory.java 2001/05/25 16:21:49 1.2 +++ FBManagedConnectionFactory.java 2001/06/14 04:48:01 1.3 @@ -36,8 +36,11 @@ import javax.transaction.xa.XAResource; +import java.io.PrintWriter; import java.util.Set; import java.util.HashMap; +import java.util.ArrayList; +import java.util.Iterator; import java.util.LinkedList; import java.util.NoSuchElementException; @@ -49,7 +52,9 @@ import org.firebirdsql.gds.GDS; import org.firebirdsql.gds.GDSException; import org.firebirdsql.gds.Clumplet; -import org.firebirdsql.jgds.GDS_Impl; +import org.firebirdsql.gds.GDSFactory; +import org.firebirdsql.jdbc.FBDataSource; +import org.firebirdsql.jdbc.FBStatement; /** * @@ -68,8 +73,10 @@ */ public class FBManagedConnectionFactory implements ManagedConnectionFactory { - - GDS gds = new GDS_Impl(); + + private PrintWriter log = new PrintWriter(System.out); + + GDS gds = GDSFactory.newGDS(); private String dbAlias; @@ -77,6 +84,10 @@ private HashMap xidMap = new HashMap(); //Maps supplied XID to internal transaction handle. + private HashMap TransactionStatementMap = new HashMap(); //Maps transaction handle to list of statements with resultsets. + + private FBConnectionRequestInfo defaultCri; + private Clumplet dpbClumplet; private Set tpbSet; @@ -95,14 +106,23 @@ return dbAlias; } - public void setDpb(Clumplet dpb) { - dpbClumplet = dpb; + public void setConnectionRequestInfo(FBConnectionRequestInfo cri) { + this.defaultCri = cri; } - public Clumplet getDpb() { - return dpbClumplet; + public FBConnectionRequestInfo getDefaultConnectionRequestInfo() { + return defaultCri; } +/* public void setDpb(Clumplet dpb) { + dpbClumplet = dpb; + }*/ + +/* public Clumplet getDpb() { +// return dpbClumplet; + return defaultCri.c; + }*/ + public void setTpb(Set tpb) { tpbSet = tpb; } @@ -126,7 +146,7 @@ ResourceAdapterInternalException - Resource adapter related error condition **/ public java.lang.Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException { - throw new ResourceException("not yet implemented"); + return new FBDataSource(this, cxManager); } @@ -144,7 +164,7 @@ **/ public java.lang.Object createConnectionFactory() throws ResourceException { - throw new ResourceException("not yet implemented"); + return new FBDataSource(this, new FBStandAloneConnectionManager()); } @@ -172,8 +192,10 @@ public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException { - //ignore ConnectionRequestInfo till we think of something to use it for. - return new FBManagedConnection(subject, this); + if (cxRequestInfo == null) { + cxRequestInfo = defaultCri; + } + return new FBManagedConnection(subject, (FBConnectionRequestInfo)cxRequestInfo, this); } @@ -237,8 +259,8 @@ **/ - public void setLogWriter(java.io.PrintWriter out) throws ResourceException { - throw new ResourceException("not yet implemented"); + public void setLogWriter(PrintWriter out) throws ResourceException { + this.log = out; } @@ -258,8 +280,8 @@ ResourceException - generic exception **/ - public java.io.PrintWriter getLogWriter() throws ResourceException { - throw new ResourceException("not yet implemented"); + public PrintWriter getLogWriter() { + return log; } @@ -302,8 +324,6 @@ } //needs synchronization! - //Also needs to use firebirds multi-db transactions! - //returns uninitialized tr_handle if first use. isc_tr_handle getCurrentIscTrHandle(Xid xid, FBManagedConnection mc, int flags) throws XAException { isc_tr_handle tr = lookupXid(xid); if (tr == null) { @@ -330,7 +350,7 @@ } - isc_db_handle getDbHandle() throws XAException { + isc_db_handle getDbHandle(FBConnectionRequestInfo cri) throws XAException { try { synchronized (freeDbHandles) { return (isc_db_handle)freeDbHandles.removeLast(); @@ -338,7 +358,7 @@ } catch (NoSuchElementException e) { isc_db_handle db = gds.get_new_isc_db_handle(); try { - gds.isc_attach_database(dbAlias, db, getDpb()); + gds.isc_attach_database(dbAlias, db, cri.getDpb()); } catch (GDSException ge) { throw new XAException(ge.toString()); @@ -351,9 +371,13 @@ freeDbHandles.addLast(db); } + + void commit(Xid xid) throws XAException { + isc_tr_handle tr = lookupXid(xid); + forgetResultSets(tr); try { - gds.isc_commit_transaction(lookupXid(xid)); + gds.isc_commit_transaction(tr); } catch (GDSException ge) { throw new XAException(ge.toString()); @@ -384,8 +408,10 @@ } void rollback(Xid xid) throws XAException { + isc_tr_handle tr = lookupXid(xid); + forgetResultSets(tr); try { - gds.isc_rollback_transaction(lookupXid(xid)); + gds.isc_rollback_transaction(tr); } catch (GDSException ge) { throw new XAException(ge.toString()); @@ -394,16 +420,34 @@ forgetXid(xid); } } - - -/*public at the moment, at the top - private Clumplet getDpb() { - return dpbClumplet; + + void registerStatementWithTransaction(isc_tr_handle tr, FBStatement stmt) { + ArrayList stmts = null; + synchronized (tr) { + stmts = (ArrayList)TransactionStatementMap.get(tr); + if (stmts == null) { + stmts = new ArrayList(); + TransactionStatementMap.put(tr, stmts); + } + } + stmts.add(stmt); } - private Set getTpb() { - return tpbSet; - }*/ + private void forgetResultSets(isc_tr_handle tr) { + //shouldn't need synchronization, only called by rollback and commit- then we're done + //transaction/thread should also help. + ArrayList stmts = (ArrayList)TransactionStatementMap.get(tr); + if (stmts != null) { + Iterator i = stmts.iterator(); + while (i.hasNext()) { + ((FBStatement)i.next()).forgetResultSet(); + } + stmts.clear(); + } + } + + + } Index: FBStandAloneConnectionManager.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/FBStandAloneConnectionManager.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -U3 -r1.1.1.1 -r1.2 --- FBStandAloneConnectionManager.java 2001/05/09 14:28:40 1.1.1.1 +++ FBStandAloneConnectionManager.java 2001/06/14 04:48:01 1.2 @@ -26,11 +26,17 @@ // imports -------------------------------------- +import java.io.PrintWriter; + +import javax.resource.ResourceException; + +import javax.resource.spi.ConnectionEvent; +import javax.resource.spi.ConnectionEventListener; import javax.resource.spi.ConnectionRequestInfo; import javax.resource.spi.ConnectionManager; +import javax.resource.spi.ManagedConnection; import javax.resource.spi.ManagedConnectionFactory; -import javax.resource.ResourceException; /** @@ -65,8 +71,13 @@ **/ -public class FBStandAloneConnectionManager implements ConnectionManager { +public class FBStandAloneConnectionManager implements ConnectionManager , ConnectionEventListener { + + //package constructor + FBStandAloneConnectionManager() { + } + //javax.resource.spi.ConnectionManager implementation /** The method allocateConnection gets called by the resource adapter's connection factory @@ -92,11 +103,43 @@ **/ public java.lang.Object allocateConnection(ManagedConnectionFactory mcf, - ConnectionRequestInfo cxRequestInfo) - throws ResourceException { - throw new ResourceException("not yet implemented"); + ConnectionRequestInfo cxRequestInfo) + throws ResourceException { + + ManagedConnection mc = ((FBManagedConnectionFactory)mcf).createManagedConnection(null, cxRequestInfo); + mc.addConnectionEventListener(this); + return mc.getConnection(null, null); } - - - + + + //javax.resource.spi.ConnectionEventListener implementation + + public void connectionClosed(ConnectionEvent ce) { + PrintWriter log = ((FBManagedConnection)ce.getSource()).getLogWriter(); + try { + ((FBManagedConnection)ce.getSource()).destroy(); + } + catch (ResourceException e) { + log.println("Exception closing unmanaged connection: " + e); + } + + } + + public void connectionErrorOccurred(ConnectionEvent ce) { + PrintWriter log = ((FBManagedConnection)ce.getSource()).getLogWriter(); + try { + ((FBManagedConnection)ce.getSource()).destroy(); + } + catch (ResourceException e) { + log.println("Exception closing unmanaged connection: " + e); + } + } + + //We are only supposed to be notified of local transactions that a Connection started. + //Not much we can do with this info... + public void localTransactionStarted(ConnectionEvent event) {} + + public void localTransactionCommitted(ConnectionEvent event) {} + + public void localTransactionRolledback(ConnectionEvent event) {} } Index: TestFBManagedConnectionFactory.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/jca/TestFBManagedConnectionFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- TestFBManagedConnectionFactory.java 2001/05/25 19:58:17 1.2 +++ TestFBManagedConnectionFactory.java 2001/06/14 04:48:01 1.3 @@ -11,11 +11,16 @@ import javax.resource.spi.*; import javax.transaction.xa.*; import java.sql.Connection; +import java.sql.Statement; //import org.firebirdsql.jca.*; import org.firebirdsql.gds.Clumplet; import org.firebirdsql.gds.GDS; +import org.firebirdsql.gds.GDSFactory; import org.firebirdsql.jgds.GDS_Impl; +import org.firebirdsql.management.FBManager; +import org.firebirdsql.jdbc.FBConnection; + import java.io.*; import java.util.Properties; import java.util.HashSet; @@ -41,16 +46,8 @@ *This is a class that hands out connections. Initial implementation uses DriverManager.getConnection, *future enhancements will use datasources/ managed stuff. */ -public class TestFBManagedConnectionFactory extends TestCase { - - static final String dbName = "localhost/3050:/usr/local/firebird/dev/client-java/db/jbosstest.gdb"; - static final String dbName2 = "localhost:/usr/local/firebird/dev/client-java/db/testdb2.gdb"; - -// private FBManagedConnectionFactory mcf; - -// private Clumplet dpb; +public class TestFBManagedConnectionFactory extends TestXABase { -// private HashSet tpb; public TestFBManagedConnectionFactory(String name) { super(name); @@ -61,23 +58,24 @@ return new TestSuite(TestFBManagedConnectionFactory.class); } - public FBManagedConnectionFactory initMcf() { - - FBManagedConnectionFactory mcf = new FBManagedConnectionFactory(); - mcf.setDatabase(dbName); - GDS gds = new GDS_Impl(); - Clumplet dpb = gds.newClumplet(GDS.isc_dpb_num_buffers, new byte[] {90}); - dpb.append(gds.newClumplet(GDS.isc_dpb_dummy_packet_interval, new byte[] {120, 10, 0, 0})); - mcf.setDpb(dpb); - HashSet tpb = new HashSet(); - tpb.add(new Integer(GDS.isc_tpb_write)); - tpb.add(new Integer(GDS.isc_tpb_read_committed)); - tpb.add(new Integer(GDS.isc_tpb_no_rec_version)); - tpb.add(new Integer(GDS.isc_tpb_wait)); - mcf.setTpb(tpb); - return mcf; + public void _setUp() throws Exception { + FBManager m = new FBManager(); + m.setURL("localhost"); + m.setPort(3050); + m.start(); + m.createDatabase(DBNAME); + m.stop(); + } + + public void _tearDown() throws Exception { + FBManager m = new FBManager(); + m.setURL("localhost"); + m.setPort(3050); + m.start(); + m.dropDatabase(DBNAME); + m.stop(); } - + @@ -95,426 +93,77 @@ System.out.println("testCreateMc"); FBManagedConnectionFactory mcf = initMcf(); ManagedConnection mc = mcf.createManagedConnection(null, null); + mc.destroy(); } - public void testCreateC() throws Exception { - System.out.println(); - System.out.println("testCreateC"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - Connection c = (Connection)mc.getConnection(null, null); - } - - public void testAssociateC() throws Exception { - System.out.println(); - System.out.println("testAssociateC"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc1 = mcf.createManagedConnection(null, null); - Connection c1 = (Connection)mc1.getConnection(null, null); - ManagedConnection mc2 = mcf.createManagedConnection(null, null); - Connection c2 = (Connection)mc2.getConnection(null, null); - mc1.associateConnection(c2); - mc2.associateConnection(c1); - } - public void testCreateStatement() throws Exception { - System.out.println(); - System.out.println("testCreateStatement"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - Connection c = (Connection)mc.getConnection(null, null); - Statement s = c.createStatement(); - } - - public void testUseStatement() throws Exception { + + public void testSqlInfo() throws Exception { System.out.println(); - System.out.println("testCreateStatement"); + System.out.println("testSqlInfo"); + byte[] testbuffer = { +23, //isc_info_sql_records +29, //length +0, +15, //isc_info_req_update_count +4,//length +0, +4, +0, +0, +0, +16,//isc_info_req_delete_count +4,//length +0, +3, +0, +0, +0, +13,//isc_info_req_select_count +4,//length +0, +2, +0, +0, +0, +14,//isc_info_req_insert_count +4,//length +0, +1, +0, +0, +0, +1, //isc_info_end +21, //isc_info_sql_stmt_type +4, //length +0, +2, //isc_info_sql_stmt_insert +0, +0, +0, +1, //isc_info_end +0, +0, +0, +0, +0, +0, +0, +0, +0, +0}; FBManagedConnectionFactory mcf = initMcf(); ManagedConnection mc = mcf.createManagedConnection(null, null); - Connection c = (Connection)mc.getConnection(null, null); - Statement s = c.createStatement(); - XAResource xa = mc.getXAResource(); - Xid xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - s.execute("CREATE TABLE T1 ( C1 SMALLINT, C2 SMALLINT)"); - xa.end(xid, XAResource.TMNOFLAGS); - xa.commit(xid, true); + FBManagedConnection.SqlInfo si = new FBManagedConnection.SqlInfo(testbuffer, GDSFactory.newGDS()); - xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - s.execute("DROP TABLE T1"); - xa.end(xid, XAResource.TMNOFLAGS); - xa.commit(xid, true); + assert("selectcount wrong " + si.getSelectCount(), si.getSelectCount() == 2); + assert("insertcount wrong " + si.getInsertCount(), si.getInsertCount() == 1); + assert("updatecount wrong " + si.getUpdateCount(), si.getUpdateCount() == 4); + assert("deletecount wrong " + si.getDeleteCount(), si.getDeleteCount() == 3); + assert("statement type wrong " + si.getStatementType(), si.getStatementType() == 2); + mc.destroy(); } - - public void testGetXAResource() throws Exception { - System.out.println(); - System.out.println("testGetXAResource"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - XAResource xa1 = mc.getXAResource(); - XAResource xa2 = mc.getXAResource(); - if (xa1 != xa2) { - throw new Exception("XAResources do not match from same mc"); - } - } - - public void testIsSameRM() throws Exception { - System.out.println(); - System.out.println("testIsSameRM"); - FBManagedConnectionFactory mcf1 = initMcf(); - ManagedConnection mc1 = mcf1.createManagedConnection(null, null); - XAResource xa1 = mc1.getXAResource(); - ManagedConnection mc2 = mcf1.createManagedConnection(null, null); - XAResource xa2 = mc2.getXAResource(); - FBManagedConnectionFactory mcf3 = initMcf(); - ManagedConnection mc3 = mcf3.createManagedConnection(null, null); - XAResource xa3 = mc3.getXAResource(); - if (!xa1.isSameRM(xa2)) { - throw new Exception("isSameRM reports difference from same mcf"); - } - if (xa1.isSameRM(xa3)) { - throw new Exception("isSameRM reports no difference from different mcf"); - } - } - - public void testStartXATrans() throws Exception { - System.out.println(); - System.out.println("testStartXATrans"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc = (FBManagedConnection)mc; - XAResource xa = mc.getXAResource(); - Xid xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - if (fbmc.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - xa.end(xid, XAResource.TMNOFLAGS); - xa.commit(xid, true); - } - - public void testRollbackXATrans() throws Exception { - System.out.println(); - System.out.println("testStartXATrans"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc = (FBManagedConnection)mc; - XAResource xa = mc.getXAResource(); - Xid xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - if (fbmc.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - xa.end(xid, XAResource.TMNOFLAGS); - xa.rollback(xid); - } - - public void test2PCXATrans() throws Exception { - System.out.println(); - System.out.println("testStartXATrans"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc = (FBManagedConnection)mc; - XAResource xa = mc.getXAResource(); - Xid xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - if (fbmc.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - xa.end(xid, XAResource.TMNOFLAGS); - xa.prepare(xid); - xa.commit(xid, false); - } - - public void testRollback2PCXATrans() throws Exception { - System.out.println(); - System.out.println("testStartXATrans"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc = (FBManagedConnection)mc; - XAResource xa = mc.getXAResource(); - Xid xid = new XidImpl(); - xa.start(xid, XAResource.TMNOFLAGS); - if (fbmc.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - xa.end(xid, XAResource.TMNOFLAGS); - xa.prepare(xid); - xa.rollback(xid); - } - - public void testDo2XATrans() throws Exception { - System.out.println(); - System.out.println("testDo2XATrans"); - FBManagedConnectionFactory mcf = initMcf(); - ManagedConnection mc1 = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc1 = (FBManagedConnection)mc1; - XAResource xa1 = mc1.getXAResource(); - Xid xid1 = new XidImpl(); - xa1.start(xid1, XAResource.TMNOFLAGS); - if (fbmc1.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - ManagedConnection mc2 = mcf.createManagedConnection(null, null); - FBManagedConnection fbmc2 = (FBManagedConnection)mc2; - XAResource xa2 = mc2.getXAResource(); - Xid xid2 = new XidImpl(); - xa2.start(xid2, XAResource.TMNOFLAGS); - if (fbmc2.getIscDBHandle() == null) { - throw new Exception("no db handle after start xid"); - } - //commit each tr on other xares - xa1.end(xid1, XAResource.TMNOFLAGS); - xa2.commit(xid1, true); - xa2.end(xid2, XAResource.TMNOFLAGS); - xa1.commit(xid2, true); - - } - - /*Borrowed from - * JBoss, the OpenSource EJB server - * - * Distributable under LGPL license. - * See terms of license at gnu.org. - */ - /* - package org.firebirdsql.jca.test; - - import java.net.InetAddress; - import java.net.UnknownHostException; - - import javax.transaction.xa.Xid; - */ - - /** - * This object encapsulates the ID of a transaction. - * This implementation is immutable and always serializable at runtime. - * - * @see TransactionImpl - * @author Rickard Öberg (ric...@te...) - * @author <a href="mailto:os...@sp...">Ole Husgaard</a> - * @version $Revision$ - */ - public static class XidImpl - implements Xid, java.io.Serializable - { - // Constants ----------------------------------------------------- - - public static final int JBOSS_FORMAT_ID = 0x0101; - - // Attributes ---------------------------------------------------- - - /** - * Hash code of this instance. This is really a sequence number. - */ - private int hash; - - /** - * Global transaction id of this instance. - * The coding of this class depends on the fact that this variable is - * initialized in the constructor and never modified. References to - * this array are never given away, instead a clone is delivered. - */ - private byte[] globalId; - - /** - * Branch qualifier of this instance. - * This identifies the branch of a transaction. - */ - private byte[] branchId; - - // Static -------------------------------------------------------- - - /** - * The host name of this host, followed by a slash. - * - * This is used for building globally unique transaction identifiers. - * It would be safer to use the IP address, but a host name is better - * for humans to read and will do for now. - */ - private static String hostName; - - /** - * The next transaction id to use on this host. - */ - static private int nextId = 0; - - /** - * Return a new unique transaction id to use on this host. - */ - static private synchronized int getNextId() - { - return nextId++; - } - - /** - * Singleton for no branch qualifier. - */ - static private byte[] noBranchQualifier = new byte[0]; - - /** - * Initialize the <code>hostName</code> class variable. - */ - static { - try { - hostName = InetAddress.getLocalHost().getHostName() + "/"; - // Ensure room for 14 digits of serial no. - if (hostName.length() > MAXGTRIDSIZE - 15) - hostName = hostName.substring(0, MAXGTRIDSIZE - 15); - hostName = hostName + "/"; - } catch (UnknownHostException e) { - hostName = "localhost/"; - } - } - - /** - * Return a string that describes any Xid instance. - */ - static String toString(Xid id) { - if (id == null) - return "[NULL Xid]"; - - String s = id.getClass().getName(); - s = s.substring(s.lastIndexOf('.') + 1); - s = s + " [FormatId=" + id.getFormatId() + - ", GlobalId=" + new String(id.getGlobalTransactionId()).trim() + - ", BranchQual=" + new String(id.getBranchQualifier()).trim()+"]"; - - return s; - } - - // Constructors -------------------------------------------------- - - /** - * Create a new instance. - */ - public XidImpl() - { - hash = getNextId(); - globalId = (hostName + Integer.toString(hash)).getBytes(); - branchId = noBranchQualifier; - } - - /** - * Create a new branch of an existing global transaction ID. - * - * @param xid The transaction ID to create a new branch of. - * @param branchId The ID of the new branch. - * - */ - public XidImpl(XidImpl xid, int branchId) - { - this.hash = xid.hash; - this.globalId = xid.globalId; // reuse array instance, we never modify. - this.branchId = Integer.toString(branchId).getBytes(); - } - - // Public -------------------------------------------------------- - - // Xid implementation -------------------------------------------- - - /** - * Return the global transaction id of this transaction. - */ - public byte[] getGlobalTransactionId() - { - return (byte[])globalId.clone(); - } - - /** - * Return the branch qualifier of this transaction. - */ - public byte[] getBranchQualifier() - { - if (branchId.length == 0) - return branchId; // Zero length arrays are immutable. - else - return (byte[])branchId.clone(); - } - - /** - * Return the format identifier of this transaction. - * - * The format identifier augments the global id and specifies - * how the global id and branch qualifier should be interpreted. - */ - public int getFormatId() { - // The id we return here should be different from all other transaction - // implementations. - // Known IDs are: - // -1: Sometimes used to denote a null transaction id. - // 0: OSI TP (javadoc states OSI CCR, but that is a bit misleading - // as OSI CCR doesn't even have ACID properties. But OSI CCR and - // OSI TP do have the same id format.) - // 1: Was used by early betas of jBoss. - // 0x0101: The JBOSS_FORMAT_ID we use here. - // 0xBB14: Used by JONAS. - // 0xBB20: Used by JONAS. - - return JBOSS_FORMAT_ID; - } - - /** - * Compare for equality. - * - * Instances are considered equal if they are both instances of XidImpl, - * and if they have the same global transaction id and transaction - * branch qualifier. - */ - public boolean equals(Object obj) - { - if (obj instanceof XidImpl) { - XidImpl other = (XidImpl)obj; - - if (globalId.length != other.globalId.length || - branchId.length != other.branchId.length) - return false; - - for (int i = 0; i < globalId.length; ++i) - if (globalId[i] != other.globalId[i]) - return false; - - for (int i = 0; i < branchId.length; ++i) - if (branchId[i] != other.branchId[i]) - return false; - - return true; - } - return false; - } - - public int hashCode() - { - return hash; - } - - public String toString() - { - return toString(this); - } - - // Package protected --------------------------------------------- - - /** - * Return the global transaction id of this transaction. - * Unlike the {@link #getGlobalTransactionId()} method, this one - * returns a reference to the global id byte array that may <em>not</em> - * be changed. - */ - public byte[] getInternalGlobalTransactionId() - { - return (byte[])globalId.clone(); - } - - - // Protected ----------------------------------------------------- - - // Private ------------------------------------------------------- - - // Inner classes ------------------------------------------------- - } - } + |
From: David J. <d_j...@us...> - 2001-06-14 04:48:04
|
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/gds In directory usw-pr-cvs1:/tmp/cvs-serv7418/org/firebirdsql/gds Modified Files: GDS.java isc_stmt_handle.java Added Files: GDSFactory.java Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- GDSFactory.java ADDED --- Index: GDS.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/gds/GDS.java,v retrieving revision 1.3 retrieving revision 1.4 diff -U3 -r1.3 -r1.4 --- GDS.java 2001/05/25 19:49:52 1.3 +++ GDS.java 2001/06/14 04:48:01 1.4 @@ -202,6 +202,23 @@ final static int isc_info_sql_stmt_select_for_upd = 12; final static int isc_info_sql_stmt_set_generator = 13; + /*****************************/ + /* Request information items */ + /*****************************/ + + final static int isc_info_number_messages = 4; + final static int isc_info_max_message = 5; + final static int isc_info_max_send = 6; + final static int isc_info_max_receive = 7; + final static int isc_info_state = 8; + final static int isc_info_message_number = 9; + final static int isc_info_message_size = 10; + final static int isc_info_request_cost = 11; + final static int isc_info_access_path = 12; + final static int isc_info_req_select_count = 13; + final static int isc_info_req_insert_count = 14; + final static int isc_info_req_update_count = 15; + final static int isc_info_req_delete_count = 16; /********************/ /* ISC Error Codes */ @@ -945,6 +962,7 @@ // Database functions + void isc_create_database2(String file_name, isc_db_handle db_handle) throws GDSException; void isc_create_database(String file_name, isc_db_handle db_handle, @@ -1001,13 +1019,11 @@ void isc_dsql_alloc_statement2(isc_db_handle db_handle, isc_stmt_handle stmt_handle) throws GDSException; - void isc_dsql_describe(isc_stmt_handle stmt_handle, - int da_version, - XSQLDA xsqlda) throws GDSException; + XSQLDA isc_dsql_describe(isc_stmt_handle stmt_handle, + int da_version) throws GDSException; - void isc_dsql_describe_bind(isc_stmt_handle stmt_handle, - int da_version, - XSQLDA xsqlda) throws GDSException; + XSQLDA isc_dsql_describe_bind(isc_stmt_handle stmt_handle, + int da_version) throws GDSException; void isc_dsql_execute(isc_tr_handle tr_handle, isc_stmt_handle stmt_handle, @@ -1020,14 +1036,14 @@ XSQLDA in_xsqlda, XSQLDA out_xsqlda) throws GDSException; - void isc_dsql_execute_inmediate(isc_db_handle db_handle, + void isc_dsql_execute_immediate(isc_db_handle db_handle, isc_tr_handle tr_handle, // int length, String statement, int dialect, XSQLDA xsqlda) throws GDSException; - void isc_dsql_exec_inmed2(isc_db_handle db_handle, + void isc_dsql_exec_immed2(isc_db_handle db_handle, isc_tr_handle tr_handle, // int length, String statement, @@ -1035,19 +1051,18 @@ XSQLDA in_xsqlda, XSQLDA out_xsqlda) throws GDSException; - void isc_dsql_fetch(isc_stmt_handle stmt_handle, + Object[] isc_dsql_fetch(isc_stmt_handle stmt_handle, int da_version, XSQLDA xsqlda) throws GDSException; void isc_dsql_free_statement(isc_stmt_handle stmt_handle, int option) throws GDSException; - void isc_dsql_prepare(isc_tr_handle tr_handle, + XSQLDA isc_dsql_prepare(isc_tr_handle tr_handle, isc_stmt_handle stmt_handle, // int length, String statement, - int dialect, - XSQLDA xsqlda) throws GDSException; + int dialect) throws GDSException; void isc_dsql_set_cursor_name(isc_stmt_handle stmt_handle, String cursor_name, @@ -1070,11 +1085,12 @@ isc_stmt_handle get_new_isc_stmt_handle(); - Clumplet newClumplet(int type, String content); +/* Clumplet newClumplet(int type, String content); Clumplet newClumplet(int type); Clumplet newClumplet(int type, int content); Clumplet newClumplet(int type, byte[] content); + Clumplet cloneClumplet(Clumplet c);*/ } Index: isc_stmt_handle.java =================================================================== RCS file: /cvsroot/firebird/client-java/src/org/firebirdsql/gds/isc_stmt_handle.java,v retrieving revision 1.1 retrieving revision 1.2 diff -U3 -r1.1 -r1.2 --- isc_stmt_handle.java 2001/05/24 16:03:44 1.1 +++ isc_stmt_handle.java 2001/06/14 04:48:01 1.2 @@ -34,4 +34,10 @@ public interface isc_stmt_handle { + XSQLDA getInSqlda(); + + XSQLDA getOutSqlda(); + + void clearRows(); + } |
From: David J. <d_j...@us...> - 2001-06-14 04:48:04
|
Update of /cvsroot/firebird/client-java/src/lib In directory usw-pr-cvs1:/tmp/cvs-serv7418/lib Added Files: jmxri.jar Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- jmxri.jar ADDED --- |
From: David J. <d_j...@us...> - 2001-06-14 04:48:04
|
Update of /cvsroot/firebird/client-java/src/build In directory usw-pr-cvs1:/tmp/cvs-serv7418/build Modified Files: build.xml Added Files: build.sh Log Message: Checkin of partly working hybrid jca/jdbc driver. Datasource as ConnectionFactory for managed connection factory works, connections obtained are nearly jdbc connections: statement and prepared statement work, resultset works except for fancy fields like blobs, however transactions must be managed via connection.getLocalTransaction() similar to a javax.resource.cci.Connection. TestDBStandAloneConnectionManager shows how to set up and use the datasource. --- build.sh ADDED --- Index: build.xml =================================================================== RCS file: /cvsroot/firebird/client-java/src/build/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- build.xml 2001/05/25 16:25:23 1.2 +++ build.xml 2001/06/14 04:48:01 1.3 @@ -4,6 +4,10 @@ <!-- JDBC-JCA Driver for Firebird build file --> <!-- ======================================================================= --> +<!--NOTE IMPORTANT to run the junit tests you need to create a directory dbsrc + next to db and create an empty dialect 3 database in it called fbmctest.gdb. +Sorry, I haven'tbeen able to create a dialect 3 db dynamically yet. --> + <project name="FirebirdSQL" default="jmx.jar" basedir="../.."> <property name="Name" value="FirebirdSQL"/> @@ -25,6 +29,8 @@ <property name="build.jar-ra.dir" value="${build.dir}/jar"/> <property name="dist.dir" value="dist"/> <property name="external.dir" value="${dist.dir}/external"/> + <property name="db.dir" value="${basedir}/db"/> + <property name="dbsrc.dir" value="${basedir}/dbsrc"/> @@ -61,6 +67,10 @@ <!-- =================================================================== --> <target name="compile" depends="prepare"> <mkdir dir="${build.classes.dir}"/> + <depend srcDir="${src.dir}" + destDir="${build.classes.dir}" + cache="${build.classes.dir}"/> + <javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="off" @@ -71,7 +81,6 @@ <classpath refid="cp"/> </javac> </target> - <!-- =================================================================== --> <!-- Creates the jar archives --> <!-- =================================================================== --> @@ -88,14 +97,23 @@ </target> <target name="junit" depends="jmx.jar"> + <delete file="${db.dir}/fbmctest.gdb"/> + <copy todir="${db.dir}"> + <fileset dir="${dbsrc.dir}"/> + </copy> <junit> <classpath> <path refid="cp"/> <pathelement location="${build.classes.dir}"/> </classpath> <formatter type="plain" usefile="false"/> + <test name="org.firebirdsql.management.TestFBManager"/> <test name="org.firebirdsql.jgds.TestGds"/> <test name="org.firebirdsql.jca.TestFBManagedConnectionFactory"/> + <test name="org.firebirdsql.jca.TestFBXAResource"/> + <test name="org.firebirdsql.jca.TestFBConnection"/> + <test name="org.firebirdsql.jca.TestFBStandAloneConnectionManager"/> + <test name="org.firebirdsql.jca.TestFBResultSet"/> </junit> </target> |
From: David J. <d_j...@us...> - 2001-06-14 04:34:52
|
Update of /cvsroot/firebird/client-java/src/org/firebirdsql/management In directory usw-pr-cvs1:/tmp/cvs-serv4646/org/firebirdsql/management Log Message: Directory /cvsroot/firebird/client-java/src/org/firebirdsql/management added to the repository |
From: David J. <d_j...@us...> - 2001-06-14 04:34:52
|
Update of /cvsroot/firebird/client-java/src/resources In directory usw-pr-cvs1:/tmp/cvs-serv4646/resources Log Message: Directory /cvsroot/firebird/client-java/src/resources added to the repository |
From: Frank Schlottmann-G. <fs...@us...> - 2001-06-11 22:20:04
|
Update of /cvsroot/firebird/interbase In directory usw-pr-cvs1:/tmp/cvs-serv31847/interbase Modified Files: ChangeLog Log Message: Updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/firebird/interbase/ChangeLog,v retrieving revision 1.42 retrieving revision 1.43 diff -U3 -r1.42 -r1.43 --- ChangeLog 2001/06/09 22:20:10 1.42 +++ ChangeLog 2001/06/11 22:20:01 1.43 @@ -1,3 +1,9 @@ +2001-06-11 13:27 tamlin + + * interbase/jrd/winnt.c: + + Fixed file sharing flags + 2001-06-09 06:28 bellardo * interbase/firebird/bellardo/stress/: Makefile, main.cpp: |
From: Mike N. <ta...@us...> - 2001-06-11 11:27:57
|
Update of /cvsroot/firebird/interbase/jrd In directory usw-pr-cvs1:/tmp/cvs-serv19855 Modified Files: winnt.c Log Message: Fixed file sharing flags Index: winnt.c =================================================================== RCS file: /cvsroot/firebird/interbase/jrd/winnt.c,v retrieving revision 1.3 retrieving revision 1.4 diff -U3 -r1.3 -r1.4 --- winnt.c 2001/05/12 01:31:59 1.3 +++ winnt.c 2001/06/11 11:27:54 1.4 @@ -72,8 +72,21 @@ static BOOLEAN nt_error (TEXT *, FIL, STATUS, STATUS *); static USHORT ostype; - +#ifdef SUPERSERVER_V2 +static const DWORD g_dwShareFlags = 0; // no sharing +static const DWORD g_dwExtraFlags = FILE_FLAG_OVERLAPPED | + FILE_FLAG_NO_BUFFERING | + FILE_FLAG_RANDOM_ACCESS; +#elif SUPERSERVER +static const DWORD g_dwShareFlags = 0; // no sharing +static const DWORD g_dwExtraFlags = FILE_FLAG_RANDOM_ACCESS; +#else +static const DWORD g_dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; +static const DWORD g_dwExtraFlags = FILE_FLAG_RANDOM_ACCESS; +#endif + + /************************************** * * Add a file to an existing database. Return the sequence @@ -107,7 +120,8 @@ return sequence; } - + + void PIO_close(FIL main_file) { /************************************** @@ -141,7 +155,8 @@ } } } - + + int PIO_connection ( TEXT *file_name, USHORT *file_length) @@ -163,7 +178,8 @@ return 0; } - + + /************************************** * @@ -180,14 +196,6 @@ TEXT workspace[MAXPATHLEN]; TEXT* file_name; -#ifdef SUPERSERVER_V2 - const DWORD dwShareFlags = 0; /* no sharing */ - const DWORD dwExtraFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; -#else - const DWORD dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; - const DWORD dwExtraFlags = 0; -#endif - file_name = string; if (length) @@ -199,12 +207,11 @@ desc = CreateFile( file_name, GENERIC_READ | GENERIC_WRITE, - dwShareFlags, + g_dwShareFlags, NULL, (overwrite ? CREATE_ALWAYS : CREATE_NEW) , FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_RANDOM_ACCESS | - dwExtraFlags, + g_dwExtraFlags, 0); if (desc == INVALID_HANDLE_VALUE) @@ -229,7 +236,8 @@ return file; } - + + int PIO_expand ( TEXT *file_name, USHORT file_length, @@ -249,7 +257,8 @@ return ISC_expand_filename (file_name, file_length, expanded_name); } - + + void PIO_flush ( FIL main_file) { @@ -274,7 +283,8 @@ THD_MUTEX_UNLOCK (file->fil_mutex); } } - + + void PIO_force_write ( FIL file, USHORT flag) @@ -291,27 +301,18 @@ **************************************/ HANDLE desc; -#ifdef SUPERSERVER_V2 - const DWORD dwShareFlags = 0; /* no sharing */ - const DWORD dwExtraFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; -#else - const DWORD dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; - const DWORD dwExtraFlags = 0; -#endif - if (flag) { if (!(file->fil_flags & FIL_force_write_init)) { desc = CreateFile (file->fil_string, GENERIC_READ | GENERIC_WRITE, - dwShareFlags, + g_dwShareFlags, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | - FILE_FLAG_RANDOM_ACCESS | - dwExtraFlags, + g_dwExtraFlags, 0); if (desc == INVALID_HANDLE_VALUE) @@ -338,7 +339,8 @@ file->fil_flags &= ~FIL_force_write; } } - + + void PIO_header ( DBB dbb, SCHAR *address, @@ -432,7 +434,8 @@ } } - + + /************************************** * * Compute number of pages in file, based only on file size. @@ -456,7 +459,8 @@ ullFileSize = (((ULONGLONG)dwFileSizeHigh) << 32) + dwFileSizeLow; return (ULONG)((ullFileSize + pagesize - 1) / pagesize); } - + + /************************************** * * Compute last physically allocated page of database. @@ -499,8 +503,9 @@ return tot_pages; } - + + /************************************** * * Open a database file. If a "connection" block is provided, use @@ -519,14 +524,6 @@ TEXT temp [MAXPATHLEN], *ptr; HANDLE desc; -#ifdef SUPERSERVER_V2 - const DWORD dwShareFlags = 0; /* no sharing */ - const DWORD dwExtraFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING; -#else - const DWORD dwShareFlags = FILE_SHARE_READ | FILE_SHARE_WRITE; - const DWORD dwExtraFlags = 0; -#endif - if (string) { ptr = string; @@ -550,12 +547,11 @@ desc = CreateFile( ptr, GENERIC_READ | GENERIC_WRITE, - dwShareFlags, + g_dwShareFlags, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_RANDOM_ACCESS | - dwExtraFlags, + g_dwExtraFlags, 0); if (desc == INVALID_HANDLE_VALUE) @@ -571,8 +567,7 @@ NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | - FILE_FLAG_RANDOM_ACCESS | - dwExtraFlags, + g_dwExtraFlags, 0); if (desc == INVALID_HANDLE_VALUE) @@ -606,7 +601,8 @@ return setup_file (dbb, string, length, desc); } - + + int PIO_read ( FIL file, BDB bdb, @@ -691,7 +687,8 @@ return TRUE; } - + + #ifdef SUPERSERVER_V2 int PIO_read_ahead ( DBB dbb, @@ -790,7 +787,8 @@ return TRUE; } #endif - + + #ifdef SUPERSERVER_V2 int PIO_status ( PIOB piob, @@ -829,7 +827,8 @@ return TRUE; } #endif - + + int PIO_write ( FIL file, BDB bdb, @@ -907,7 +906,8 @@ return TRUE; } - + + #ifdef SUPERSERVER_V2 static void release_io_event ( FIL file, @@ -943,8 +943,9 @@ CloseHandle (overlapped->hEvent); } #endif - + + static FIL seek_file ( FIL file, BDB bdb, @@ -1038,7 +1039,8 @@ return file; } - + + static FIL setup_file ( DBB dbb, TEXT *file_name, @@ -1123,7 +1125,8 @@ return file; } - + + static BOOLEAN nt_error ( TEXT *string, FIL file, |
From: Frank Schlottmann-G. <fs...@us...> - 2001-06-09 22:20:13
|
Update of /cvsroot/firebird/interbase In directory usw-pr-cvs1:/tmp/cvs-serv29701/interbase Modified Files: ChangeLog Log Message: Updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/firebird/interbase/ChangeLog,v retrieving revision 1.41 retrieving revision 1.42 diff -U3 -r1.41 -r1.42 --- ChangeLog 2001/06/08 22:16:35 1.41 +++ ChangeLog 2001/06/09 22:20:10 1.42 @@ -1,3 +1,9 @@ +2001-06-09 06:28 bellardo + + * interbase/firebird/bellardo/stress/: Makefile, main.cpp: + + A very basic little stress test program. + 2001-06-08 23:38 awharrison * interbase/jrd/tra.c: |
From: John B. <bel...@us...> - 2001-06-09 04:28:39
|
Update of /cvsroot/firebird/interbase/firebird/bellardo/stress In directory usw-pr-cvs1:/tmp/cvs-serv13054 Added Files: Makefile main.cpp Log Message: A very basic little stress test program. --- Makefile ADDED --- --- main.cpp ADDED --- |
From: John B. <bel...@us...> - 2001-06-09 04:28:02
|
Update of /cvsroot/firebird/interbase/firebird/bellardo/stress In directory usw-pr-cvs1:/tmp/cvs-serv12972/stress Log Message: Directory /cvsroot/firebird/interbase/firebird/bellardo/stress added to the repository |
From: Frank Schlottmann-G. <fs...@us...> - 2001-06-08 22:16:38
|
Update of /cvsroot/firebird/interbase In directory usw-pr-cvs1:/tmp/cvs-serv17180/interbase Modified Files: ChangeLog Log Message: Updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/firebird/interbase/ChangeLog,v retrieving revision 1.40 retrieving revision 1.41 diff -U3 -r1.40 -r1.41 --- ChangeLog 2001/06/07 22:16:41 1.40 +++ ChangeLog 2001/06/08 22:16:35 1.41 @@ -1,3 +1,9 @@ +2001-06-08 23:38 awharrison + + * interbase/jrd/tra.c: + + make tip pages long + 2001-06-07 01:54 bellardo * interbase/jrd/flu.c: |
From: Ann W. H. <awh...@us...> - 2001-06-08 21:38:36
|
Update of /cvsroot/firebird/interbase/jrd In directory usw-pr-cvs1:/tmp/cvs-serv10269 Modified Files: tra.c Log Message: make tip pages long Index: tra.c =================================================================== RCS file: /cvsroot/firebird/interbase/jrd/tra.c,v retrieving revision 1.2 retrieving revision 1.3 diff -U3 -r1.2 -r1.3 --- tra.c 2001/05/13 13:37:33 1.2 +++ tra.c 2001/06/08 21:38:33 1.3 @@ -107,7 +107,7 @@ static void downgrade_lock (TRA); static void expand_view_lock (TRA, REL, SCHAR); static TIP fetch_inventory_page (TDBB, WIN *, SLONG, USHORT); -static SLONG inventory_page (TDBB, int); +static SLONG inventory_page (TDBB, SLONG); static SSHORT limbo_transaction (TDBB, SLONG); static void restart_requests (TDBB, TRA); static BOOLEAN start_sweeper (TDBB, DBB); @@ -242,8 +242,9 @@ TIP tip; ATT attachment; UCHAR *byte; -SSHORT shift, sequence, last, state; -SLONG number, ceiling, active, trans_per_tip, max, limbo, trans_offset; +SSHORT shift, state; +SLONG number, ceiling, active, trans_per_tip; +SLONG max, limbo, sequence, last, trans_offset; SET_TDBB (tdbb); dbb = tdbb->tdbb_database; @@ -557,7 +558,8 @@ * **************************************/ DBB dbb; -SLONG tip_seq, trans_per_tip; +SLONG trans_per_tip; +ULONG tip_number, tip_seq; WIN window; TIP tip; ULONG byte; @@ -569,15 +571,16 @@ /* locate and fetch the proper TIP page */ +tip_number = (ULONG) number; trans_per_tip = dbb->dbb_pcontrol->pgc_tpt; -tip_seq = number / trans_per_tip; +tip_seq = tip_number / trans_per_tip; window.win_flags = 0; tip = fetch_inventory_page (tdbb, &window, tip_seq, LCK_read); /* calculate the state of the desired transaction */ -byte = TRANS_OFFSET (number % trans_per_tip); -shift = TRANS_SHIFT (number); +byte = TRANS_OFFSET (tip_number % trans_per_tip); +shift = TRANS_SHIFT (tip_number); state = (tip->tip_transactions [byte] >> shift ) & TRA_MASK; CCH_RELEASE (tdbb, &window); @@ -607,7 +610,7 @@ **************************************/ DBB dbb; ULONG trans_per_tip; -USHORT sequence, last, l; +ULONG sequence, last, l; WIN window; TIP tip; UCHAR *p, *q; @@ -1323,8 +1326,9 @@ TIP tip; JRNI record; UCHAR *address; -SSHORT sequence, shift; -ULONG byte, trans_per_tip, generation; +SSHORT shift; +SLONG sequence; +ULONG byte, trans_per_tip; SET_TDBB (tdbb); dbb = tdbb->tdbb_database; @@ -2709,7 +2713,7 @@ #ifndef GATEWAY static SLONG inventory_page ( TDBB tdbb, - int sequence) + SLONG sequence) { /************************************** * @@ -2779,8 +2783,8 @@ WIN window; TIP tip; UCHAR *byte; -SSHORT shift, page, state; -SLONG number, trans_per_tip, trans_offset; +SSHORT shift, state; +SLONG page, number, trans_per_tip, trans_offset; SET_TDBB (tdbb); dbb = tdbb->tdbb_database; |
From: Frank Schlottmann-G. <fs...@us...> - 2001-06-07 22:16:43
|
Update of /cvsroot/firebird/interbase In directory usw-pr-cvs1:/tmp/cvs-serv8867/interbase Modified Files: ChangeLog Log Message: Updated ChangeLog Index: ChangeLog =================================================================== RCS file: /cvsroot/firebird/interbase/ChangeLog,v retrieving revision 1.39 retrieving revision 1.40 diff -U3 -r1.39 -r1.40 --- ChangeLog 2001/06/06 22:16:43 1.39 +++ ChangeLog 2001/06/07 22:16:41 1.40 @@ -1,3 +1,15 @@ +2001-06-07 01:54 bellardo + + * interbase/jrd/flu.c: + + Fixed a missing #include that caused Darwin port not to compile. + +2001-06-07 01:06 bellardo + + * interbase/jrd/flu.c: + + Added loadable module support for Darwin. + 2001-06-06 02:41 bellardo * interbase/: builds/original/prefix.darwin, jrd/sort.c: |
From: John B. <bel...@us...> - 2001-06-06 23:54:15
|
Update of /cvsroot/firebird/interbase/jrd In directory usw-pr-cvs1:/tmp/cvs-serv9514 Modified Files: flu.c Log Message: Fixed a missing #include that caused Darwin port not to compile. Index: flu.c =================================================================== RCS file: /cvsroot/firebird/interbase/jrd/flu.c,v retrieving revision 1.8 retrieving revision 1.9 diff -U3 -r1.8 -r1.9 --- flu.c 2001/06/06 23:06:15 1.8 +++ flu.c 2001/06/06 23:54:12 1.9 @@ -74,6 +74,7 @@ #ifdef DARWIN #include <unistd.h> +#include <mach-o/dyld.h> #define IB_UDF_DIR "UDF/" #endif |