Expression Testing
[csql.git] / src / jdbc / JSqlStatement.cxx
blobc7cc9f7457c40007d5a4e2dbc2815f5bb3f2281d
1 #include<AbsSqlStatement.h>
2 #include<SqlFactory.h>
3 //sqlStmtPtr
6 /* DO NOT EDIT THIS FILE - it is machine generated */
7 #include <jni.h>
8 /* Header for class JSqlStatement */
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
14 * Class: JSqlStatement
15 * Method: alloc
16 * Signature: ()V
18 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_alloc
19 (JNIEnv *env, jobject obj, jint mode)
21 jclass cls;
22 jfieldID fid;
24 AbsSqlStatement *stmt;
25 if (mode ==1 )
26 stmt = SqlFactory::createStatement(CSql);
27 else
28 stmt = SqlFactory::createStatement(CSqlGateway);
30 cls = env->GetObjectClass( obj );
31 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
32 if (fid == 0)
34 jclass Exception = env->FindClass("java/lang/Exception");
35 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
36 return;
38 env->SetLongField( obj, fid, (jlong) stmt );
39 return;
43 * Class: JSqlStatement
44 * Method: free
45 * Signature: ()V
47 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_free
48 (JNIEnv *env, jobject obj)
50 jclass cls;
51 jfieldID fid;
53 cls = env->GetObjectClass(obj);
54 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
55 if (fid == 0)
57 jclass Exception = env->FindClass("java/lang/Exception");
58 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
59 return;
61 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
62 delete stmt;
63 return;
67 * Class: JSqlStatement
68 * Method: freeStmt
69 * Signature: ()V
71 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_freeStmt
72 (JNIEnv *env, jobject obj)
74 jclass cls;
75 jfieldID fid;
77 cls = env->GetObjectClass(obj);
78 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
79 if (fid == 0)
81 jclass Exception = env->FindClass("java/lang/Exception");
82 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
83 return;
85 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid);
86 stmt->free();
87 return;
92 * Class: JSqlStatement
93 * Method: setConnectionPtr
94 * Signature: (J)V
96 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setConnectionPtr
97 (JNIEnv *env, jobject obj, jlong conn)
100 jclass cls;
101 jfieldID fid;
103 cls = env->GetObjectClass(obj);
104 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
105 if (fid == 0)
107 jclass Exception = env->FindClass("java/lang/Exception");
108 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
109 return;
111 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid);
112 stmt->setConnection((AbsSqlConnection*) conn);
113 return;
117 * Class: JSqlStatement
118 * Method: prepare
119 * Signature: (Ljava/lang/String;)I
121 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_prepare
122 (JNIEnv *env, jobject obj, jstring stmt)
124 jclass cls;
125 jfieldID fid;
127 cls = env->GetObjectClass(obj);
128 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
129 if (fid == 0)
131 jclass Exception = env->FindClass("java/lang/Exception");
132 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
133 return(-1);
135 AbsSqlStatement *s = (AbsSqlStatement*) env->GetLongField( obj, fid );
136 jboolean isCopy = JNI_TRUE;
137 char *stmtString = (char*) env->GetStringUTFChars(stmt, &isCopy );
138 int rv = s->prepare(stmtString);
139 return rv;
143 * Class: JSqlStatement
144 * Method: isSelect
145 * Signature: ()Z
147 JNIEXPORT jboolean JNICALL Java_csql_jdbc_JSqlStatement_isSelect
148 (JNIEnv *env, jobject obj)
150 jclass cls;
151 jfieldID fid;
153 cls = env->GetObjectClass(obj);
154 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
155 if (fid == 0)
157 jclass Exception = env->FindClass("java/lang/Exception");
158 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
159 return(-1);
161 AbsSqlStatement *s = (AbsSqlStatement*) env->GetLongField( obj, fid );
162 return s->isSelect();
166 * Class: JSqlStatement
167 * Method: execute
168 * Signature: ()I
170 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_execute
171 (JNIEnv *env, jobject obj)
173 jclass cls;
174 jfieldID fid;
176 cls = env->GetObjectClass(obj);
177 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
178 if (fid == 0)
180 jclass Exception = env->FindClass("java/lang/Exception");
181 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
182 return(-1);
184 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
185 int rowsAffected =0;
186 DbRetVal rv = stmt->execute(rowsAffected);
187 if (rv != OK) return -1;
188 return rowsAffected;
192 * Class: JSqlStatement
193 * Method: next
194 * Signature: ()J
196 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_next
197 (JNIEnv *env, jobject obj)
199 jclass cls;
200 jfieldID fid;
201 cls = env->GetObjectClass(obj);
202 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
203 if (fid == 0)
205 jclass Exception = env->FindClass("java/lang/Exception");
206 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
207 return(-1);
209 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
210 void *tuple = stmt->next();
211 if (NULL == tuple) return 0; else return 1;
215 * Class: JSqlStatement
216 * Method: close
217 * Signature: ()J
219 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_close
220 (JNIEnv *env, jobject obj)
222 //TODO::stmt currently does not support close
223 jclass cls;
224 jfieldID fid;
225 cls = env->GetObjectClass(obj);
226 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
227 if (fid == 0)
229 jclass Exception = env->FindClass("java/lang/Exception");
230 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
231 return(-1);
233 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
234 int rv =0;
235 rv = stmt->close();
236 return rv;
240 * Class: JSqlStatement
241 * Method: setBoolean
242 * Signature: (I)Z
244 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setBoolean
245 (JNIEnv *env, jobject obj, jint position, jint value)
249 * Class: JSqlStatement
250 * Method: setShort
251 * Signature: (IS)V
253 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setShort
254 (JNIEnv *env, jobject obj, jint position, jshort value)
256 jclass cls;
257 jfieldID fid;
259 cls = env->GetObjectClass( obj );
260 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
261 if (fid == 0)
263 jclass Exception = env->FindClass("java/lang/Exception");
264 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
265 return;
267 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
268 stmt->setShortParam(position, (short) value);
269 return;
273 * Class: JSqlStatement
274 * Method: setInt
275 * Signature: (II)V
277 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setInt
278 (JNIEnv *env, jobject obj, jint position, jint value)
280 jclass cls;
281 jfieldID fid;
283 cls = env->GetObjectClass( obj );
284 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
285 if (fid == 0)
287 jclass Exception = env->FindClass("java/lang/Exception");
288 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
289 return;
291 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
292 stmt->setIntParam(position, (int) value);
293 return;
297 * Class: JSqlStatement
298 * Method: setLong
299 * Signature: (IJ)V
301 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setLong
302 (JNIEnv *env, jobject obj, jint position, jlong value)
304 jclass cls;
305 jfieldID fid;
307 cls = env->GetObjectClass( obj );
308 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
309 if (fid == 0)
311 jclass Exception = env->FindClass("java/lang/Exception");
312 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
313 return;
315 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
316 stmt->setLongParam(position, (long) value);
317 return;
321 * Class: JSqlStatement
322 * Method: setByte
323 * Signature: (IB)V
325 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setByte
326 (JNIEnv *env, jobject obj, jint position, jbyte value)
328 jclass cls;
329 jfieldID fid;
331 cls = env->GetObjectClass( obj );
332 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
333 if (fid == 0)
335 jclass Exception = env->FindClass("java/lang/Exception");
336 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
337 return;
339 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
340 stmt->setByteIntParam(position, (ByteInt) value);
341 return;
344 * Class: JSqlStatement
345 * Method: setFloat
346 * Signature: (IF)V
348 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setFloat
349 (JNIEnv *env, jobject obj, jint position, jfloat value)
351 jclass cls;
352 jfieldID fid;
354 cls = env->GetObjectClass( obj );
355 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
356 if (fid == 0)
358 jclass Exception = env->FindClass("java/lang/Exception");
359 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
360 return;
362 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
363 stmt->setFloatParam(position, (float) value);
364 return;
368 * Class: JSqlStatement
369 * Method: setDouble
370 * Signature: (ID)V
372 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setDouble
373 (JNIEnv *env, jobject obj, jint position, jdouble value)
375 jclass cls;
376 jfieldID fid;
378 cls = env->GetObjectClass( obj );
379 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
380 if (fid == 0)
382 jclass Exception = env->FindClass("java/lang/Exception");
383 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
384 return;
386 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
387 stmt->setDoubleParam(position, (double) value);
388 return;
392 * Class: JSqlStatement
393 * Method: setString
394 * Signature: (ILjava/lang/String;)V
396 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setString
397 (JNIEnv *env, jobject obj, jint position, jstring value)
399 jclass cls;
400 jfieldID fid;
402 cls = env->GetObjectClass( obj );
403 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
404 if (fid == 0)
406 jclass Exception = env->FindClass("java/lang/Exception");
407 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
408 return;
411 jboolean isCopy = JNI_TRUE;
412 char *valueStr = (char*) env->GetStringUTFChars( value, &isCopy );
414 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
415 stmt->setStringParam(position, valueStr);
416 return;
420 * Class: JSqlStatement
421 * Method: setDate
422 * Signature: (ILjava/sql/Date;)V
424 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setDate
425 (JNIEnv *env, jobject obj, jint position, jobject dateObj)
428 jclass cls, datecls;
429 jfieldID fid;
430 jmethodID dateMethod;
432 cls = env->GetObjectClass( obj );
433 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
434 if (fid == 0)
436 jclass Exception = env->FindClass("java/lang/Exception");
437 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
438 return;
440 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
442 // Get date, month, year from java object
443 int d, m, y;
444 datecls = env->GetObjectClass( dateObj );
445 dateMethod = env->GetMethodID( datecls, "getYear", "()I");
446 y = env->CallIntMethod( dateObj, dateMethod);
447 dateMethod = env->GetMethodID( datecls, "getMonth", "()I");
448 m = env->CallIntMethod( dateObj, dateMethod);
449 dateMethod = env->GetMethodID( datecls, "getDate", "()I");
450 d = env->CallIntMethod( dateObj, dateMethod);
452 Date date(y + 1900, m + 1, d);
453 stmt->setDateParam(position, date);
455 return;
460 * Class: JSqlStatement
461 * Method: setTime
462 * Signature: (ILjava/sql/Time;)V
464 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setTime
465 (JNIEnv *env, jobject obj, jint position, jobject timeObj)
468 jclass cls, timecls;
469 jfieldID fid;
470 jmethodID timeMethod;
472 cls = env->GetObjectClass( obj );
473 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
474 if (fid == 0)
476 jclass Exception = env->FindClass("java/lang/Exception");
477 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
478 return;
480 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
482 // Get hour, minures, secs from java object
483 int h, m, s;
484 timecls = env->GetObjectClass( timeObj );
485 timeMethod = env->GetMethodID( timecls, "getHours", "()I");
486 h = env->CallIntMethod( timeObj, timeMethod);
487 timeMethod = env->GetMethodID( timecls, "getMinutes", "()I");
488 m = env->CallIntMethod( timeObj, timeMethod);
489 timeMethod = env->GetMethodID( timecls, "getSeconds", "()I");
490 s = env->CallIntMethod( timeObj, timeMethod);
492 Time time(h, m, s, 0);
493 stmt->setTimeParam(position, time);
495 return;
499 * Class: JSqlStatement
500 * Method: setTimestamp
501 * Signature: (ILjava/sql/Timestamp;)V
503 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setTimestamp
504 (JNIEnv *env, jobject obj, jint position, jobject timeObj)
507 jclass cls, timecls;
508 jfieldID fid;
509 jmethodID timeMethod;
511 cls = env->GetObjectClass( obj );
512 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
513 if (fid == 0)
515 jclass Exception = env->FindClass("java/lang/Exception");
516 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
517 return;
519 AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
521 // Get year, month, day, hour, minutes, secs from java object
522 int y, mo, d, h, mn, s;
523 timecls = env->GetObjectClass( timeObj );
525 timeMethod = env->GetMethodID( timecls, "getYear", "()I");
526 y = env->CallIntMethod( timeObj, timeMethod );
527 timeMethod = env->GetMethodID( timecls, "getMonth", "()I");
528 mo = env->CallIntMethod( timeObj, timeMethod );
529 timeMethod = env->GetMethodID( timecls, "getDate", "()I");
530 d = env->CallIntMethod( timeObj, timeMethod );
531 timeMethod = env->GetMethodID( timecls, "getHours", "()I");
532 h = env->CallIntMethod( timeObj, timeMethod);
533 timeMethod = env->GetMethodID( timecls, "getMinutes", "()I");
534 mn = env->CallIntMethod( timeObj, timeMethod);
535 timeMethod = env->GetMethodID( timecls, "getSeconds", "()I");
536 s = env->CallIntMethod( timeObj, timeMethod);
538 TimeStamp timeStamp(y + 1900, mo + 1, d, h, mn, s, 0);
539 stmt->setTimeStampParam(position, timeStamp);
541 return;
545 * Class: JSqlStatement
546 * Method: getShort
547 * Signature: (I)S
549 JNIEXPORT jshort JNICALL Java_csql_jdbc_JSqlStatement_getShort
550 (JNIEnv *env, jobject obj, jint pos)
552 jclass cls;
553 jfieldID fid;
555 cls = env->GetObjectClass( obj );
556 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
557 if (fid == 0)
559 jclass Exception = env->FindClass("java/lang/Exception");
560 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
561 return(-1);
563 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
565 // Validate pos
566 // Handle conversion
568 // Read data at column
569 void *fvp = sqlStmt->getFieldValuePtr( pos );
570 return( * ((short*)fvp) );
574 * Class: JSqlStatement
575 * Method: setNull
576 * Signature: (I)V
578 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setNull
579 (JNIEnv *, jobject, jint);
582 * Class: JSqlStatement
583 * Method: getInt
584 * Signature: (I)I
586 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_getInt
587 (JNIEnv *env, jobject obj, jint pos)
589 jclass cls;
590 jfieldID fid;
592 cls = env->GetObjectClass( obj );
593 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
594 if (fid == 0)
596 jclass Exception = env->FindClass("java/lang/Exception");
597 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
598 return(-1);
600 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
602 // Validate pos
603 // Handle conversion
605 // Read data at column
606 void *fvp = sqlStmt->getFieldValuePtr( pos );
607 return( * ((int*)fvp) );
611 * Class: JSqlStatement
612 * Method: getLong
613 * Signature: (I)J
615 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_getLong
616 (JNIEnv *env, jobject obj, jint pos)
618 jclass cls;
619 jfieldID fid;
621 cls = env->GetObjectClass( obj );
622 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
623 if (fid == 0)
625 jclass Exception = env->FindClass("java/lang/Exception");
626 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
627 return(-1);
629 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
631 // Validate pos
632 // Handle conversion
634 // Read data at column
635 void *fvp = sqlStmt->getFieldValuePtr( pos );
636 return( * ((long*)fvp) );
640 * Class: JSqlStatement
641 * Method: getByte
642 * Signature: (I)B
644 JNIEXPORT jbyte JNICALL Java_csql_jdbc_JSqlStatement_getByte
645 (JNIEnv *env, jobject obj, jint pos)
647 jclass cls;
648 jfieldID fid;
650 cls = env->GetObjectClass( obj );
651 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
652 if (fid == 0)
654 jclass Exception = env->FindClass("java/lang/Exception");
655 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
656 return(-1);
658 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
660 // Validate pos
661 // Handle conversion
663 // Read data at column
664 void *fvp = sqlStmt->getFieldValuePtr( pos );
665 return( * ((char*)fvp) );
669 * Class: JSqlStatement
670 * Method: getFloat
671 * Signature: (I)F
673 JNIEXPORT jfloat JNICALL Java_csql_jdbc_JSqlStatement_getFloat
674 (JNIEnv *env, jobject obj, jint pos)
676 jclass cls;
677 jfieldID fid;
679 cls = env->GetObjectClass( obj );
680 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
681 if (fid == 0)
683 jclass Exception = env->FindClass("java/lang/Exception");
684 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
685 return(-1);
687 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
689 // Validate pos
690 // Handle conversion
692 // Read data at column
693 void *fvp = sqlStmt->getFieldValuePtr( pos );
694 return( * ((float*)fvp) );
698 * Class: JSqlStatement
699 * Method: getDouble
700 * Signature: (I)D
702 JNIEXPORT jdouble JNICALL Java_csql_jdbc_JSqlStatement_getDouble
703 (JNIEnv *env, jobject obj, jint pos)
705 jclass cls;
706 jfieldID fid;
708 cls = env->GetObjectClass( obj );
709 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
710 if (fid == 0)
712 jclass Exception = env->FindClass("java/lang/Exception");
713 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
714 return(-1);
716 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
718 // Validate pos
719 // Handle conversion
721 // Read data at column
722 void *fvp = sqlStmt->getFieldValuePtr( pos );
723 return( * ((double*)fvp) );
727 * Class: JSqlStatement
728 * Method: getString
729 * Signature: (I)Ljava/lang/String;
731 JNIEXPORT jstring JNICALL Java_csql_jdbc_JSqlStatement_getString
732 (JNIEnv *env, jobject obj, jint pos)
734 jclass cls;
735 jfieldID fid;
737 cls = env->GetObjectClass( obj );
738 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
739 if (fid == 0)
741 jclass Exception = env->FindClass("java/lang/Exception");
742 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
743 return( (jstring) 0 );
745 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
747 // Validate pos
748 // Handle conversion
750 // Read data at column
751 void *fvp = sqlStmt->getFieldValuePtr( pos );
752 return( env->NewStringUTF( (char*) fvp ) );
756 * Class: JSqlStatement
757 * Method: getBytes
758 * Signature: (I)[B
760 JNIEXPORT jbyteArray JNICALL Java_csql_jdbc_JSqlStatement_getBytes
761 (JNIEnv *, jobject, jint);
764 * Class: JSqlStatement
765 * Method: getDate
766 * Signature: (I)Ljava/sql/Date;
768 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getDate
769 (JNIEnv *env, jobject obj, jint pos)
771 jclass cls;
772 jfieldID fid;
774 cls = env->GetObjectClass( obj );
775 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
776 if (fid == 0)
778 jclass Exception = env->FindClass("java/lang/Exception");
779 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
780 return( (jobject) 0 );
782 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
784 // Validate pos
785 // Handle conversion
787 // Read data at column
788 void *fvp = sqlStmt->getFieldValuePtr( pos );
790 // Create Java Object
791 jclass cDate = env->FindClass("java/sql/Date");
792 jmethodID methodID = env->GetMethodID( cDate, "<init>", "(III)V" );
793 jobject dateObj;
795 Date *dt = (Date*) fvp;
796 dateObj = env->NewObject( cDate, methodID,
797 (jint) dt->year()-1900, (jint) dt->month() - 1,
798 (jint) dt->dayOfMonth() );
800 return( dateObj );
804 * Class: JSqlStatement
805 * Method: getTime
806 * Signature: (I)Ljava/sql/Time;
808 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getTime
809 (JNIEnv *env, jobject obj, jint pos)
811 jclass cls;
812 jfieldID fid;
814 cls = env->GetObjectClass( obj );
815 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
816 if (fid == 0)
818 jclass Exception = env->FindClass("java/lang/Exception");
819 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
820 return( (jobject) 0 );
822 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
824 // Validate pos
825 // Handle conversion
827 // Read data at column
828 void *fvp = sqlStmt->getFieldValuePtr( pos );
830 // Create Java Object
831 jclass cTime = env->FindClass("java/sql/Time");
832 jmethodID methodID = env->GetMethodID( cTime, "<init>", "(III)V" );
833 jobject timeObj;
835 Time *tm = (Time*) fvp;
836 timeObj = env->NewObject( cTime, methodID,
837 (jint) tm->hours(), (jint) tm->minutes(),
838 (jint) tm->seconds() );
840 return( timeObj );
844 * Class: JSqlStatement
845 * Method: getTimestamp
846 * Signature: (I)Ljava/sql/Timestamp;
848 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getTimestamp
849 (JNIEnv *env, jobject obj, jint pos)
851 jclass cls;
852 jfieldID fid;
854 cls = env->GetObjectClass( obj );
855 fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
856 if (fid == 0)
858 jclass Exception = env->FindClass("java/lang/Exception");
859 env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
860 return( (jobject) 0 );
862 AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
864 // Validate pos
865 // Handle conversion
867 // Read data at column
868 void *fvp = sqlStmt->getFieldValuePtr( pos );
870 // Create Java Object
871 jclass cTimestamp = env->FindClass("java/sql/Timestamp");
872 jmethodID methodID = env->GetMethodID( cTimestamp, "<init>", "(IIIIIII)V" );
873 jobject timeObj;
875 TimeStamp *ts = (TimeStamp*) fvp;
876 timeObj = env->NewObject( cTimestamp, methodID, \
877 (jint) ts->year()-1900, (jint) ts->month() - 1, (jint) ts->dayOfMonth(), \
878 (jint) ts->hours(), (jint) ts->minutes(), (jint) ts->seconds(), (jint) 0 );
880 return( timeObj );
884 * Class: JSqlStatement
885 * Method: getBoolean
886 * Signature: (I)Z
888 JNIEXPORT jboolean JNICALL Java_csql_jdbc_JSqlStatement_getBoolean
889 (JNIEnv *, jobject, jint);
891 #ifdef __cplusplus
893 #endif