55
55
56
56
#if defined(__WIN__)
57
57
extern " C" HINSTANCE s_hModule; // Saved module handle
58
- #else // ! __WIN__
58
+ #endif // __WIN__
59
59
#define nullptr 0
60
- #endif // !__WIN__
61
60
62
61
TYPCONV GetTypeConv ();
63
62
int GetConvSize ();
@@ -1442,7 +1441,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
1442
1441
PGLOBAL& g = m_G;
1443
1442
bool rc = false ;
1444
1443
PVAL val = colp->GetValue ();
1445
- jint n, i = (jint)colp->GetRank ();
1444
+ jint n, jrc = 0 , i = (jint)colp->GetRank ();
1446
1445
jshort s;
1447
1446
jlong lg;
1448
1447
// jfloat f;
@@ -1452,69 +1451,74 @@ bool JDBConn::SetParam(JDBCCOL *colp)
1452
1451
jstring jst = nullptr ;
1453
1452
jmethodID dtc, setid = nullptr ;
1454
1453
1455
- switch (val->GetType ()) {
1456
- case TYPE_STRING:
1457
- if (gmID (g, setid, " SetStringParm" , " (ILjava/lang/String;)V" ))
1454
+ if (val->GetNullable () && val->IsNull ()) {
1455
+ if (gmID (g, setid, " SetNullParm" , " (II)I" ))
1458
1456
return true ;
1459
1457
1460
- jst = env->NewStringUTF (val->GetCharValue ());
1461
- env->CallVoidMethod (job, setid, i, jst);
1462
- break ;
1463
- case TYPE_INT:
1464
- if (gmID (g, setid, " SetIntParm" , " (II)V" ))
1465
- return true ;
1466
-
1467
- n = (jint)val->GetIntValue ();
1468
- env->CallVoidMethod (job, setid, i, n);
1469
- break ;
1470
- case TYPE_TINY:
1471
- case TYPE_SHORT:
1472
- if (gmID (g, setid, " SetShortParm" , " (IS)V" ))
1473
- return true ;
1458
+ jrc = env->CallIntMethod (job, setid, i, (jint)GetJDBCType (val->GetType ()));
1459
+ } else switch (val->GetType ()) {
1460
+ case TYPE_STRING:
1461
+ if (gmID (g, setid, " SetStringParm" , " (ILjava/lang/String;)V" ))
1462
+ return true ;
1474
1463
1475
- s = (jshort) val->GetShortValue ( );
1476
- env->CallVoidMethod (job, setid, i, s );
1477
- break ;
1478
- case TYPE_BIGINT :
1479
- if (gmID (g, setid, " SetBigintParm " , " (IJ )V" ))
1480
- return true ;
1464
+ jst = env-> NewStringUTF ( val->GetCharValue () );
1465
+ env->CallVoidMethod (job, setid, i, jst );
1466
+ break ;
1467
+ case TYPE_INT :
1468
+ if (gmID (g, setid, " SetIntParm " , " (II )V" ))
1469
+ return true ;
1481
1470
1482
- lg = (jlong )val->GetBigintValue ();
1483
- env->CallVoidMethod (job, setid, i, lg );
1484
- break ;
1485
- case TYPE_DOUBLE :
1486
- case TYPE_DECIM :
1487
- if (gmID (g, setid, " SetDoubleParm " , " (ID )V" ))
1488
- return true ;
1471
+ n = (jint )val->GetIntValue ();
1472
+ env->CallVoidMethod (job, setid, i, n );
1473
+ break ;
1474
+ case TYPE_TINY :
1475
+ case TYPE_SHORT :
1476
+ if (gmID (g, setid, " SetShortParm " , " (IS )V" ))
1477
+ return true ;
1489
1478
1490
- d = (jdouble)val->GetFloatValue ();
1491
- env->CallVoidMethod (job, setid, i, d);
1492
- break ;
1493
- case TYPE_DATE:
1494
- if ((dat = env->FindClass (" java/sql/Timestamp" )) == nullptr ) {
1495
- strcpy (g->Message , " Cannot find Timestamp class" );
1496
- return true ;
1497
- } else if (!(dtc = env->GetMethodID (dat, " <init>" , " (J)V" ))) {
1498
- strcpy (g->Message , " Cannot find Timestamp class constructor" );
1499
- return true ;
1500
- } // endif's
1479
+ s = (jshort)val->GetShortValue ();
1480
+ env->CallVoidMethod (job, setid, i, s);
1481
+ break ;
1482
+ case TYPE_BIGINT:
1483
+ if (gmID (g, setid, " SetBigintParm" , " (IJ)V" ))
1484
+ return true ;
1501
1485
1502
- lg = (jlong)val->GetBigintValue () * 1000 ;
1486
+ lg = (jlong)val->GetBigintValue ();
1487
+ env->CallVoidMethod (job, setid, i, lg);
1488
+ break ;
1489
+ case TYPE_DOUBLE:
1490
+ case TYPE_DECIM:
1491
+ if (gmID (g, setid, " SetDoubleParm" , " (ID)V" ))
1492
+ return true ;
1503
1493
1504
- if ((datobj = env->NewObject (dat, dtc, lg)) == nullptr ) {
1505
- strcpy (g->Message , " Cannot make Timestamp object" );
1506
- return true ;
1507
- } else if (gmID (g, setid, " SetTimestampParm" , " (ILjava/sql/Timestamp;)V" ))
1494
+ d = (jdouble)val->GetFloatValue ();
1495
+ env->CallVoidMethod (job, setid, i, d);
1496
+ break ;
1497
+ case TYPE_DATE:
1498
+ if ((dat = env->FindClass (" java/sql/Timestamp" )) == nullptr ) {
1499
+ strcpy (g->Message , " Cannot find Timestamp class" );
1500
+ return true ;
1501
+ } else if (!(dtc = env->GetMethodID (dat, " <init>" , " (J)V" ))) {
1502
+ strcpy (g->Message , " Cannot find Timestamp class constructor" );
1503
+ return true ;
1504
+ } // endif's
1505
+
1506
+ lg = (jlong)val->GetBigintValue () * 1000 ;
1507
+
1508
+ if ((datobj = env->NewObject (dat, dtc, lg)) == nullptr ) {
1509
+ strcpy (g->Message , " Cannot make Timestamp object" );
1510
+ return true ;
1511
+ } else if (gmID (g, setid, " SetTimestampParm" , " (ILjava/sql/Timestamp;)V" ))
1512
+ return true ;
1513
+
1514
+ env->CallVoidMethod (job, setid, i, datobj);
1515
+ break ;
1516
+ default :
1517
+ sprintf (g->Message , " Parm type %d not supported" , val->GetType ());
1508
1518
return true ;
1519
+ } // endswitch Type
1509
1520
1510
- env->CallVoidMethod (job, setid, i, datobj);
1511
- break ;
1512
- default :
1513
- sprintf (g->Message , " Parm type %d not supported" , val->GetType ());
1514
- return true ;
1515
- } // endswitch Type
1516
-
1517
- if (Check ()) {
1521
+ if (Check (jrc)) {
1518
1522
sprintf (g->Message , " SetParam: col=%s msg=%s" , colp->GetName (), Msg);
1519
1523
rc = true ;
1520
1524
} // endif msg
0 commit comments