src/jdbc/JSqlStatement.cxx

Go to the documentation of this file.
00001 #include<AbsSqlStatement.h>
00002 #include<SqlFactory.h>
00003 //sqlStmtPtr
00004 
00005 
00006 /* DO NOT EDIT THIS FILE - it is machine generated */
00007 #include <jni.h>
00008 /* Header for class JSqlStatement */
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 /*
00014  * Class:     JSqlStatement
00015  * Method:    alloc
00016  * Signature: ()V
00017  */
00018 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_alloc
00019   (JNIEnv *env, jobject obj, jint mode)
00020 {
00021     jclass cls;
00022     jfieldID fid;
00023 
00024     AbsSqlStatement *stmt;
00025     if (mode ==1 )
00026         stmt = SqlFactory::createStatement(CSql);
00027     else
00028         stmt = SqlFactory::createStatement(CSqlGateway);
00029 
00030     cls = env->GetObjectClass( obj );
00031     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00032     if (fid == 0)
00033     {
00034         jclass Exception = env->FindClass("java/lang/Exception");
00035         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00036         return;
00037     }
00038     env->SetLongField( obj, fid, (jlong) stmt );
00039     return;
00040 }
00041 
00042 /*
00043  * Class:     JSqlStatement
00044  * Method:    free
00045  * Signature: ()V
00046  */
00047 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_free
00048   (JNIEnv *env, jobject obj)
00049 {
00050     jclass cls;
00051     jfieldID fid;
00052 
00053     cls = env->GetObjectClass(obj);
00054     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00055     if (fid == 0)
00056     {
00057         jclass Exception = env->FindClass("java/lang/Exception");
00058         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00059         return;
00060     }
00061     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00062     delete stmt;
00063     return;
00064 }
00065 
00066 /*
00067  * Class:     JSqlStatement
00068  * Method:    freeStmt
00069  * Signature: ()V
00070  */
00071 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_freeStmt
00072   (JNIEnv *env, jobject obj)
00073 {
00074     jclass cls;
00075     jfieldID fid;
00076 
00077     cls = env->GetObjectClass(obj);
00078     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00079     if (fid == 0)
00080     {
00081         jclass Exception = env->FindClass("java/lang/Exception");
00082         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00083         return;
00084     }
00085     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid);
00086     stmt->free();
00087     return;
00088 
00089 }
00090 
00091 /*
00092  * Class:     JSqlStatement
00093  * Method:    setConnectionPtr
00094  * Signature: (J)V
00095  */
00096 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setConnectionPtr
00097   (JNIEnv *env, jobject obj, jlong conn)
00098 {
00099 
00100     jclass cls;
00101     jfieldID fid;
00102 
00103     cls = env->GetObjectClass(obj);
00104     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00105     if (fid == 0)
00106     {
00107         jclass Exception = env->FindClass("java/lang/Exception");
00108         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00109         return;
00110     }
00111     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid);
00112     stmt->setConnection((AbsSqlConnection*) conn);
00113     return;
00114 }
00115 
00116 /*
00117  * Class:     JSqlStatement
00118  * Method:    prepare
00119  * Signature: (Ljava/lang/String;)I
00120  */
00121 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_prepare
00122   (JNIEnv *env, jobject obj, jstring stmt)
00123 {
00124     jclass cls;
00125     jfieldID fid;
00126 
00127     cls = env->GetObjectClass(obj);
00128     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00129     if (fid == 0)
00130     {
00131         jclass Exception = env->FindClass("java/lang/Exception");
00132         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00133         return(-1);
00134     }
00135     AbsSqlStatement *s = (AbsSqlStatement*) env->GetLongField( obj, fid );
00136     jboolean isCopy = JNI_TRUE;
00137     char *stmtString = (char*) env->GetStringUTFChars(stmt, &isCopy );
00138     int rv = s->prepare(stmtString);
00139     return rv;
00140 }
00141 
00142 /*
00143  * Class:     JSqlStatement
00144  * Method:    isSelect
00145  * Signature: ()Z
00146  */
00147 JNIEXPORT jboolean JNICALL Java_csql_jdbc_JSqlStatement_isSelect
00148   (JNIEnv *env, jobject obj)
00149 {
00150     jclass cls;
00151     jfieldID fid;
00152 
00153     cls = env->GetObjectClass(obj);
00154     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00155     if (fid == 0)
00156     {
00157         jclass Exception = env->FindClass("java/lang/Exception");
00158         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00159         return(-1);
00160     }
00161     AbsSqlStatement *s = (AbsSqlStatement*) env->GetLongField( obj, fid );
00162     return s->isSelect();
00163 }
00164 
00165 /*
00166  * Class:     JSqlStatement
00167  * Method:    execute
00168  * Signature: ()I
00169  */
00170 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_execute
00171   (JNIEnv *env, jobject obj)
00172 {
00173     jclass cls;
00174     jfieldID fid;
00175 
00176     cls = env->GetObjectClass(obj);
00177     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00178     if (fid == 0)
00179     {
00180         jclass Exception = env->FindClass("java/lang/Exception");
00181         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00182         return(-1);
00183     }
00184     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00185     int rowsAffected =0;
00186     DbRetVal rv = stmt->execute(rowsAffected);
00187     if (rv != OK) return -1;
00188     return rowsAffected;
00189 }
00190 
00191 /*
00192  * Class:     JSqlStatement
00193  * Method:    next
00194  * Signature: ()J
00195  */
00196 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_next
00197   (JNIEnv *env, jobject obj)
00198 {
00199     jclass cls;
00200     jfieldID fid;
00201     cls = env->GetObjectClass(obj);
00202     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00203     if (fid == 0)
00204     {
00205         jclass Exception = env->FindClass("java/lang/Exception");
00206         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00207         return(-1);
00208     }
00209     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00210     void *tuple = stmt->next();
00211     if (NULL == tuple) return 0; else return 1;
00212 }
00213 
00214 /*
00215  * Class:     JSqlStatement
00216  * Method:    close
00217  * Signature: ()J
00218  */
00219 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_close
00220   (JNIEnv *env, jobject obj)
00221 {
00222    //TODO::stmt currently does not support close
00223     jclass cls;
00224     jfieldID fid;
00225     cls = env->GetObjectClass(obj);
00226     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00227     if (fid == 0)
00228     {
00229         jclass Exception = env->FindClass("java/lang/Exception");
00230         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00231         return(-1);
00232     }
00233     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00234     int rv =0;
00235     rv  = stmt->close();
00236     return rv;
00237 }
00238 
00239 /*
00240  * Class:     JSqlStatement
00241  * Method:    setBoolean
00242  * Signature: (I)Z
00243  */
00244 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setBoolean
00245   (JNIEnv *env, jobject obj, jint position, jint value)
00246 {};
00247 
00248 /*
00249  * Class:     JSqlStatement
00250  * Method:    setShort
00251  * Signature: (IS)V
00252  */
00253 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setShort
00254   (JNIEnv *env, jobject obj, jint position, jshort value)
00255 {
00256     jclass cls;
00257     jfieldID fid;
00258 
00259     cls = env->GetObjectClass( obj );
00260     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00261     if (fid == 0)
00262     {
00263         jclass Exception = env->FindClass("java/lang/Exception");
00264         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00265         return;
00266     }
00267     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00268     stmt->setShortParam(position, (short) value);
00269     return;
00270 }
00271 
00272 /*
00273  * Class:     JSqlStatement
00274  * Method:    setInt
00275  * Signature: (II)V
00276  */
00277 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setInt
00278   (JNIEnv *env, jobject obj, jint position, jint value)
00279 {
00280     jclass cls;
00281     jfieldID fid;
00282 
00283     cls = env->GetObjectClass( obj );
00284     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00285     if (fid == 0)
00286     {
00287         jclass Exception = env->FindClass("java/lang/Exception");
00288         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00289         return;
00290     }
00291     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00292     stmt->setIntParam(position, (int) value);
00293     return;
00294 }
00295 
00296 /*
00297  * Class:     JSqlStatement
00298  * Method:    setLong
00299  * Signature: (IJ)V
00300  */
00301 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setLong
00302   (JNIEnv *env, jobject obj, jint position, jlong value)
00303 {
00304     jclass cls;
00305     jfieldID fid;
00306 
00307     cls = env->GetObjectClass( obj );
00308     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00309     if (fid == 0)
00310     {
00311         jclass Exception = env->FindClass("java/lang/Exception");
00312         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00313         return;
00314     }
00315     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00316     stmt->setLongParam(position, (long) value);
00317     return;
00318 }
00319 
00320 /*
00321  * Class:     JSqlStatement
00322  * Method:    setByte
00323  * Signature: (IB)V
00324  */
00325 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setByte
00326   (JNIEnv *env, jobject obj, jint position, jbyte value)
00327 {
00328     jclass cls;
00329     jfieldID fid;
00330 
00331     cls = env->GetObjectClass( obj );
00332     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00333     if (fid == 0)
00334     {
00335         jclass Exception = env->FindClass("java/lang/Exception");
00336         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00337         return;
00338     }
00339     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00340     stmt->setByteIntParam(position, (ByteInt) value);
00341     return;
00342 }
00343 /*
00344  * Class:     JSqlStatement
00345  * Method:    setFloat
00346  * Signature: (IF)V
00347  */
00348 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setFloat
00349   (JNIEnv *env, jobject obj, jint position, jfloat value)
00350 {
00351     jclass cls;
00352     jfieldID fid;
00353 
00354     cls = env->GetObjectClass( obj );
00355     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00356     if (fid == 0)
00357     {
00358         jclass Exception = env->FindClass("java/lang/Exception");
00359         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00360         return;
00361     }
00362     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00363     stmt->setFloatParam(position, (float) value);
00364     return;
00365 }
00366 
00367 /*
00368  * Class:     JSqlStatement
00369  * Method:    setDouble
00370  * Signature: (ID)V
00371  */
00372 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setDouble
00373   (JNIEnv *env, jobject obj, jint position, jdouble value)
00374 {
00375     jclass cls;
00376     jfieldID fid;
00377 
00378     cls = env->GetObjectClass( obj );
00379     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00380     if (fid == 0)
00381     {
00382         jclass Exception = env->FindClass("java/lang/Exception");
00383         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00384         return;
00385     }
00386     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00387     stmt->setDoubleParam(position, (double) value);
00388     return;
00389 }
00390 
00391 /*
00392  * Class:     JSqlStatement
00393  * Method:    setString
00394  * Signature: (ILjava/lang/String;)V
00395  */
00396 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setString
00397   (JNIEnv *env, jobject obj, jint position, jstring value)
00398 {
00399     jclass cls;
00400     jfieldID fid;
00401 
00402     cls = env->GetObjectClass( obj );
00403     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00404     if (fid == 0)
00405     {
00406         jclass Exception = env->FindClass("java/lang/Exception");
00407         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00408         return;
00409     }
00410 
00411     jboolean isCopy = JNI_TRUE;
00412     char *valueStr = (char*) env->GetStringUTFChars( value, &isCopy );
00413 
00414     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00415     stmt->setStringParam(position, valueStr);
00416     return;
00417 }
00418 
00419 /*
00420  * Class:     JSqlStatement
00421  * Method:    setDate
00422  * Signature: (ILjava/sql/Date;)V
00423  */
00424 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setDate
00425   (JNIEnv *env, jobject obj, jint position, jobject dateObj)
00426 
00427 {
00428     jclass cls, datecls;
00429     jfieldID fid;
00430     jmethodID dateMethod;
00431 
00432     cls = env->GetObjectClass( obj );
00433     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00434     if (fid == 0)
00435     {
00436         jclass Exception = env->FindClass("java/lang/Exception");
00437         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00438         return;
00439     }
00440     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00441 
00442     // Get date, month, year from java object
00443     int d, m, y;
00444     datecls = env->GetObjectClass( dateObj );
00445     dateMethod = env->GetMethodID( datecls, "getYear", "()I");
00446     y = env->CallIntMethod( dateObj, dateMethod);
00447     dateMethod = env->GetMethodID( datecls, "getMonth", "()I");
00448     m = env->CallIntMethod( dateObj, dateMethod);
00449     dateMethod = env->GetMethodID( datecls, "getDate", "()I");
00450     d = env->CallIntMethod( dateObj, dateMethod);
00451 
00452     Date date(y + 1900, m + 1, d);
00453     stmt->setDateParam(position, date);
00454 
00455     return;
00456 }
00457 
00458 
00459 /*
00460  * Class:     JSqlStatement
00461  * Method:    setTime
00462  * Signature: (ILjava/sql/Time;)V
00463  */
00464 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setTime
00465   (JNIEnv *env, jobject obj, jint position, jobject timeObj)
00466 
00467 {
00468     jclass cls, timecls;
00469     jfieldID fid;
00470     jmethodID timeMethod;
00471 
00472     cls = env->GetObjectClass( obj );
00473     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00474     if (fid == 0)
00475     {
00476         jclass Exception = env->FindClass("java/lang/Exception");
00477         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00478         return;
00479     }
00480     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00481 
00482     // Get hour, minures, secs from java object
00483     int h, m, s;
00484     timecls = env->GetObjectClass( timeObj );
00485     timeMethod = env->GetMethodID( timecls, "getHours", "()I");
00486     h = env->CallIntMethod( timeObj, timeMethod);
00487     timeMethod = env->GetMethodID( timecls, "getMinutes", "()I");
00488     m = env->CallIntMethod( timeObj, timeMethod);
00489     timeMethod = env->GetMethodID( timecls, "getSeconds", "()I");
00490     s = env->CallIntMethod( timeObj, timeMethod);
00491 
00492     Time time(h, m, s, 0);
00493     stmt->setTimeParam(position, time);
00494 
00495     return;
00496 }
00497 
00498 /*
00499  * Class:     JSqlStatement
00500  * Method:    setTimestamp
00501  * Signature: (ILjava/sql/Timestamp;)V
00502  */
00503 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setTimestamp
00504   (JNIEnv *env, jobject obj, jint position, jobject timeObj)
00505 
00506 {
00507     jclass cls, timecls;
00508     jfieldID fid;
00509     jmethodID timeMethod;
00510 
00511     cls = env->GetObjectClass( obj );
00512     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00513     if (fid == 0)
00514     {
00515         jclass Exception = env->FindClass("java/lang/Exception");
00516         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00517         return;
00518     }
00519     AbsSqlStatement *stmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00520 
00521     // Get year, month, day, hour, minutes, secs from java object
00522     int y, mo, d, h, mn, s;
00523     timecls = env->GetObjectClass( timeObj );
00524 
00525     timeMethod = env->GetMethodID( timecls, "getYear", "()I");
00526     y = env->CallIntMethod( timeObj, timeMethod );
00527     timeMethod = env->GetMethodID( timecls, "getMonth", "()I");
00528     mo = env->CallIntMethod( timeObj, timeMethod );
00529     timeMethod = env->GetMethodID( timecls, "getDate", "()I");
00530     d = env->CallIntMethod( timeObj, timeMethod );
00531     timeMethod = env->GetMethodID( timecls, "getHours", "()I");
00532     h = env->CallIntMethod( timeObj, timeMethod);
00533     timeMethod = env->GetMethodID( timecls, "getMinutes", "()I");
00534     mn = env->CallIntMethod( timeObj, timeMethod);
00535     timeMethod = env->GetMethodID( timecls, "getSeconds", "()I");
00536     s = env->CallIntMethod( timeObj, timeMethod);
00537 
00538     TimeStamp timeStamp(y + 1900, mo + 1, d, h, mn, s, 0);
00539     stmt->setTimeStampParam(position, timeStamp);
00540 
00541     return;
00542 }
00543 
00544 /*
00545  * Class:     JSqlStatement
00546  * Method:    getShort
00547  * Signature: (I)S
00548  */
00549 JNIEXPORT jshort JNICALL Java_csql_jdbc_JSqlStatement_getShort
00550   (JNIEnv *env, jobject obj, jint pos)
00551 {
00552     jclass cls;
00553     jfieldID fid;
00554 
00555     cls = env->GetObjectClass( obj );
00556     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00557     if (fid == 0) 
00558     {
00559         jclass Exception = env->FindClass("java/lang/Exception");
00560         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00561         return(-1);
00562     }
00563     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00564 
00565     // Validate pos
00566     // Handle conversion
00567 
00568     // Read data at column
00569     void *fvp = sqlStmt->getFieldValuePtr( pos );
00570     return( * ((short*)fvp) );
00571 }
00572 
00573 /*
00574  * Class:     JSqlStatement
00575  * Method:    setNull
00576  * Signature: (I)V
00577  */
00578 JNIEXPORT void JNICALL Java_csql_jdbc_JSqlStatement_setNull
00579   (JNIEnv *, jobject, jint);
00580 
00581 /*
00582  * Class:     JSqlStatement
00583  * Method:    getInt
00584  * Signature: (I)I
00585  */
00586 JNIEXPORT jint JNICALL Java_csql_jdbc_JSqlStatement_getInt
00587   (JNIEnv *env, jobject obj, jint pos)
00588 {
00589     jclass cls;
00590     jfieldID fid;
00591 
00592     cls = env->GetObjectClass( obj );
00593     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00594     if (fid == 0) 
00595     {
00596         jclass Exception = env->FindClass("java/lang/Exception");
00597         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00598         return(-1);
00599     }
00600     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00601 
00602     // Validate pos
00603     // Handle conversion
00604 
00605     // Read data at column
00606     void *fvp = sqlStmt->getFieldValuePtr( pos );
00607     return( * ((int*)fvp) );
00608 }
00609 
00610 /*
00611  * Class:     JSqlStatement
00612  * Method:    getLong
00613  * Signature: (I)J
00614  */
00615 JNIEXPORT jlong JNICALL Java_csql_jdbc_JSqlStatement_getLong
00616   (JNIEnv *env, jobject obj, jint pos)
00617 {
00618     jclass cls;
00619     jfieldID fid;
00620 
00621     cls = env->GetObjectClass( obj );
00622     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00623     if (fid == 0) 
00624     {
00625         jclass Exception = env->FindClass("java/lang/Exception");
00626         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00627         return(-1);
00628     }
00629     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00630 
00631     // Validate pos
00632     // Handle conversion
00633 
00634     // Read data at column
00635     void *fvp = sqlStmt->getFieldValuePtr( pos );
00636     return( * ((long*)fvp) );
00637 }
00638 
00639 /*
00640  * Class:     JSqlStatement
00641  * Method:    getByte
00642  * Signature: (I)B
00643  */
00644 JNIEXPORT jbyte JNICALL Java_csql_jdbc_JSqlStatement_getByte
00645   (JNIEnv *env, jobject obj, jint pos)
00646 {
00647     jclass cls;
00648     jfieldID fid;
00649 
00650     cls = env->GetObjectClass( obj );
00651     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00652     if (fid == 0) 
00653     {
00654         jclass Exception = env->FindClass("java/lang/Exception");
00655         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00656         return(-1);
00657     }
00658     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00659 
00660     // Validate pos
00661     // Handle conversion
00662 
00663     // Read data at column
00664     void *fvp = sqlStmt->getFieldValuePtr( pos );
00665     return( * ((char*)fvp) );
00666 }
00667 
00668 /*
00669  * Class:     JSqlStatement
00670  * Method:    getFloat
00671  * Signature: (I)F
00672  */
00673 JNIEXPORT jfloat JNICALL Java_csql_jdbc_JSqlStatement_getFloat
00674   (JNIEnv *env, jobject obj, jint pos)
00675 {
00676     jclass cls;
00677     jfieldID fid;
00678 
00679     cls = env->GetObjectClass( obj );
00680     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00681     if (fid == 0) 
00682     {
00683         jclass Exception = env->FindClass("java/lang/Exception");
00684         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00685         return(-1);
00686     }
00687     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00688 
00689     // Validate pos
00690     // Handle conversion
00691 
00692     // Read data at column
00693     void *fvp = sqlStmt->getFieldValuePtr( pos );
00694     return( * ((float*)fvp) );
00695 }
00696 
00697 /*
00698  * Class:     JSqlStatement
00699  * Method:    getDouble
00700  * Signature: (I)D
00701  */
00702 JNIEXPORT jdouble JNICALL Java_csql_jdbc_JSqlStatement_getDouble
00703   (JNIEnv *env, jobject obj, jint pos)
00704 {
00705     jclass cls;
00706     jfieldID fid;
00707 
00708     cls = env->GetObjectClass( obj );
00709     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00710     if (fid == 0) 
00711     {
00712         jclass Exception = env->FindClass("java/lang/Exception");
00713         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00714         return(-1);
00715     }
00716     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00717 
00718     // Validate pos
00719     // Handle conversion
00720 
00721     // Read data at column
00722     void *fvp = sqlStmt->getFieldValuePtr( pos );
00723     return( * ((double*)fvp) );
00724 }
00725 
00726 /*
00727  * Class:     JSqlStatement
00728  * Method:    getString
00729  * Signature: (I)Ljava/lang/String;
00730  */
00731 JNIEXPORT jstring JNICALL Java_csql_jdbc_JSqlStatement_getString
00732   (JNIEnv *env, jobject obj, jint pos)
00733 {
00734     jclass cls;
00735     jfieldID fid;
00736 
00737     cls = env->GetObjectClass( obj );
00738     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00739     if (fid == 0) 
00740     {
00741         jclass Exception = env->FindClass("java/lang/Exception");
00742         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00743         return( (jstring) 0 );
00744     }
00745     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00746 
00747     // Validate pos
00748     // Handle conversion
00749 
00750     // Read data at column
00751     void *fvp = sqlStmt->getFieldValuePtr( pos );
00752     return( env->NewStringUTF( (char*) fvp ) );
00753 }
00754 
00755 /*
00756  * Class:     JSqlStatement
00757  * Method:    getBytes
00758  * Signature: (I)[B
00759  */
00760 JNIEXPORT jbyteArray JNICALL Java_csql_jdbc_JSqlStatement_getBytes
00761   (JNIEnv *, jobject, jint);
00762 
00763 /*
00764  * Class:     JSqlStatement
00765  * Method:    getDate
00766  * Signature: (I)Ljava/sql/Date;
00767  */
00768 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getDate
00769   (JNIEnv *env, jobject obj, jint pos)
00770 {
00771     jclass cls;
00772     jfieldID fid;
00773 
00774     cls = env->GetObjectClass( obj );
00775     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00776     if (fid == 0) 
00777     {
00778         jclass Exception = env->FindClass("java/lang/Exception");
00779         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00780         return( (jobject) 0 );
00781     }
00782     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00783 
00784     // Validate pos
00785     // Handle conversion
00786 
00787     // Read data at column
00788     void *fvp = sqlStmt->getFieldValuePtr( pos );
00789 
00790     // Create Java Object
00791     jclass cDate = env->FindClass("java/sql/Date"); 
00792     jmethodID methodID = env->GetMethodID( cDate, "<init>", "(III)V" );
00793     jobject dateObj;
00794 
00795     Date *dt = (Date*) fvp;
00796     dateObj = env->NewObject( cDate, methodID, 
00797         (jint) dt->year()-1900, (jint) dt->month() - 1, 
00798         (jint) dt->dayOfMonth() );
00799 
00800     return( dateObj );
00801 }
00802 
00803 /*
00804  * Class:     JSqlStatement
00805  * Method:    getTime
00806  * Signature: (I)Ljava/sql/Time;
00807  */
00808 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getTime
00809   (JNIEnv *env, jobject obj, jint pos)
00810 {
00811     jclass cls;
00812     jfieldID fid;
00813 
00814     cls = env->GetObjectClass( obj );
00815     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00816     if (fid == 0) 
00817     {
00818         jclass Exception = env->FindClass("java/lang/Exception");
00819         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00820         return( (jobject) 0 );
00821     }
00822     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00823 
00824     // Validate pos
00825     // Handle conversion
00826 
00827     // Read data at column
00828     void *fvp = sqlStmt->getFieldValuePtr( pos );
00829 
00830     // Create Java Object
00831     jclass cTime = env->FindClass("java/sql/Time"); 
00832     jmethodID methodID = env->GetMethodID( cTime, "<init>", "(III)V" );
00833     jobject timeObj;
00834 
00835     Time *tm = (Time*) fvp;
00836     timeObj = env->NewObject( cTime, methodID, 
00837         (jint) tm->hours(), (jint) tm->minutes(), 
00838         (jint) tm->seconds() );
00839 
00840     return( timeObj );
00841 }
00842 
00843 /*
00844  * Class:     JSqlStatement
00845  * Method:    getTimestamp
00846  * Signature: (I)Ljava/sql/Timestamp;
00847  */
00848 JNIEXPORT jobject JNICALL Java_csql_jdbc_JSqlStatement_getTimestamp
00849   (JNIEnv *env, jobject obj, jint pos)
00850 {
00851     jclass cls;
00852     jfieldID fid;
00853 
00854     cls = env->GetObjectClass( obj );
00855     fid = env->GetFieldID( cls, "sqlStmtPtr", "J");
00856     if (fid == 0) 
00857     {
00858         jclass Exception = env->FindClass("java/lang/Exception");
00859         env->ThrowNew(Exception,"JNI: GetFieldID failed.\n");
00860         return( (jobject) 0 );
00861     }
00862     AbsSqlStatement *sqlStmt = (AbsSqlStatement*) env->GetLongField( obj, fid );
00863 
00864     // Validate pos
00865     // Handle conversion
00866 
00867     // Read data at column
00868     void *fvp = sqlStmt->getFieldValuePtr( pos );
00869 
00870     // Create Java Object
00871     jclass cTimestamp = env->FindClass("java/sql/Timestamp"); 
00872     jmethodID methodID = env->GetMethodID( cTimestamp, "<init>", "(IIIIIII)V" );
00873     jobject timeObj;
00874 
00875     TimeStamp *ts = (TimeStamp*) fvp;
00876     timeObj = env->NewObject( cTimestamp, methodID, \
00877         (jint) ts->year()-1900, (jint) ts->month() - 1, (jint) ts->dayOfMonth(), \
00878         (jint) ts->hours(), (jint) ts->minutes(), (jint) ts->seconds(), (jint) 0 );
00879 
00880     return( timeObj );
00881 }
00882 
00883 /*
00884  * Class:     JSqlStatement
00885  * Method:    getBoolean
00886  * Signature: (I)Z
00887  */
00888 JNIEXPORT jboolean JNICALL Java_csql_jdbc_JSqlStatement_getBoolean
00889   (JNIEnv *, jobject, jint);
00890 
00891 #ifdef __cplusplus
00892 }
00893 #endif

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7