2727import com .google .cloud .bigquery .TableId ;
2828import com .google .cloud .bigquery .exception .BigQueryJdbcException ;
2929import com .google .cloud .bigquery .exception .BigQueryJdbcRuntimeException ;
30+ import com .google .cloud .bigquery .exception .BigQueryJdbcSqlFeatureNotSupportedException ;
3031import com .google .cloud .bigquery .storage .v1 .BatchCommitWriteStreamsRequest ;
3132import com .google .cloud .bigquery .storage .v1 .BatchCommitWriteStreamsResponse ;
3233import com .google .cloud .bigquery .storage .v1 .BigQueryWriteClient ;
5556import java .sql .SQLXML ;
5657import java .sql .Time ;
5758import java .sql .Timestamp ;
59+ import java .sql .Types ;
5860import java .util .ArrayList ;
5961import java .util .Arrays ;
6062import java .util .Calendar ;
@@ -114,8 +116,10 @@ public void clearParameters() {
114116 }
115117
116118 @ Override
117- public void setNull (int parameterIndex , int sqlType ) {
118- // TODO(neenu): implement null case
119+ public void setNull (int parameterIndex , int sqlType ) throws SQLException {
120+ checkClosed ();
121+ Class <?> javaType = BigQueryJdbcTypeMappings .getJavaType (sqlType );
122+ this .parameterHandler .setParameter (parameterIndex , null , javaType );
119123 }
120124
121125 @ Override
@@ -131,8 +135,9 @@ public void setByte(int parameterIndex, byte x) throws SQLException {
131135 }
132136
133137 @ Override
134- public void setShort (int parameterIndex , short x ) {
135- // TODO(neenu): implement Bytes conversion.
138+ public void setShort (int parameterIndex , short x ) throws SQLException {
139+ checkClosed ();
140+ this .parameterHandler .setParameter (parameterIndex , x , Short .class );
136141 }
137142
138143 @ Override
@@ -172,8 +177,9 @@ public void setString(int parameterIndex, String x) throws SQLException {
172177 }
173178
174179 @ Override
175- public void setBytes (int parameterIndex , byte [] x ) {
176- // TODO(neenu): implement Bytes conversion.
180+ public void setBytes (int parameterIndex , byte [] x ) throws SQLException {
181+ checkClosed ();
182+ this .parameterHandler .setParameter (parameterIndex , x , byte [].class );
177183 }
178184
179185 @ Override
@@ -218,11 +224,24 @@ public void setBinaryStream(int parameterIndex, InputStream x, int length) {
218224 }
219225
220226 @ Override
221- public void setObject (int parameterIndex , Object x , int targetSqlType ) {}
227+ public void setObject (int parameterIndex , Object x , int targetSqlType ) throws SQLException {
228+ checkClosed ();
229+ if (x == null ) {
230+ setNull (parameterIndex , targetSqlType );
231+ return ;
232+ }
233+ Class <?> javaType = BigQueryJdbcTypeMappings .getJavaType (targetSqlType );
234+ this .parameterHandler .setParameter (parameterIndex , x , javaType );
235+ }
222236
223237 @ Override
224- public void setObject (int parameterIndex , Object x ) {
225- // TODO :NOT IMPLEMENTED
238+ public void setObject (int parameterIndex , Object x ) throws SQLException {
239+ checkClosed ();
240+ if (x == null ) {
241+ setNull (parameterIndex , Types .NULL );
242+ return ;
243+ }
244+ this .parameterHandler .setParameter (parameterIndex , x , x .getClass ());
226245 }
227246
228247 @ Override
@@ -424,28 +443,30 @@ Boolean useWriteAPI() {
424443 }
425444
426445 @ Override
427- public void setCharacterStream (int parameterIndex , Reader reader , int length ) {
428- // TODO :NOT IMPLEMENTED
446+ public void setCharacterStream (int parameterIndex , Reader reader , int length )
447+ throws SQLException {
448+ throw new BigQueryJdbcSqlFeatureNotSupportedException ("setCharacterStream is not supported." );
429449 }
430450
431451 @ Override
432- public void setRef (int parameterIndex , Ref x ) {
433- // TODO :NOT IMPLEMENTED
452+ public void setRef (int parameterIndex , Ref x ) throws SQLException {
453+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setRef is not supported." );
434454 }
435455
436456 @ Override
437- public void setBlob (int parameterIndex , Blob x ) {
438- // TODO :NOT IMPLEMENTED
457+ public void setBlob (int parameterIndex , Blob x ) throws SQLException {
458+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setBlob is not supported." );
439459 }
440460
441461 @ Override
442- public void setClob (int parameterIndex , Clob x ) {
443- // TODO :NOT IMPLEMENTED
462+ public void setClob (int parameterIndex , Clob x ) throws SQLException {
463+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setClob is not supported." );
444464 }
445465
446466 @ Override
447- public void setArray (int parameterIndex , Array x ) {
448- // TODO(neenu) :IMPLEMENT ARRAY
467+ public void setArray (int parameterIndex , Array x ) throws SQLException {
468+ checkClosed ();
469+ this .parameterHandler .setParameter (parameterIndex , x , Array .class );
449470 }
450471
451472 @ Override
@@ -470,13 +491,13 @@ public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) {
470491 }
471492
472493 @ Override
473- public void setNull (int parameterIndex , int sqlType , String typeName ) {
474- // TODO :NOT IMPLEMENTED
494+ public void setNull (int parameterIndex , int sqlType , String typeName ) throws SQLException {
495+ setNull ( parameterIndex , sqlType );
475496 }
476497
477498 @ Override
478- public void setURL (int parameterIndex , URL x ) {
479- // TODO :NOT IMPLEMENTED
499+ public void setURL (int parameterIndex , URL x ) throws SQLException {
500+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setURL is not supported." );
480501 }
481502
482503 @ Override
@@ -486,97 +507,107 @@ public ParameterMetaData getParameterMetaData() {
486507 }
487508
488509 @ Override
489- public void setRowId (int parameterIndex , RowId x ) {
490- // TODO :NOT IMPLEMENTED
510+ public void setRowId (int parameterIndex , RowId x ) throws SQLException {
511+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setRowId is not supported." );
491512 }
492513
493514 @ Override
494- public void setNString (int parameterIndex , String value ) {
495- // TODO :NOT IMPLEMENTED
515+ public void setNString (int parameterIndex , String value ) throws SQLException {
516+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setNString is not supported." );
496517 }
497518
498519 @ Override
499- public void setNCharacterStream (int parameterIndex , Reader value , long length ) {
500- // TODO :NOT IMPLEMENTED
520+ public void setNCharacterStream (int parameterIndex , Reader value , long length )
521+ throws SQLException {
522+ throw new BigQueryJdbcSqlFeatureNotSupportedException ("setNCharacterStream is not supported." );
501523 }
502524
503525 @ Override
504- public void setNClob (int parameterIndex , NClob value ) {
505- // TODO :NOT IMPLEMENTED
526+ public void setNClob (int parameterIndex , NClob value ) throws SQLException {
527+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setNClob is not supported." );
506528 }
507529
508530 @ Override
509- public void setClob (int parameterIndex , Reader reader , long length ) {
510- // TODO :NOT IMPLEMENTED
531+ public void setClob (int parameterIndex , Reader reader , long length ) throws SQLException {
532+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setClob is not supported." );
511533 }
512534
513535 @ Override
514- public void setBlob (int parameterIndex , InputStream inputStream , long length ) {
515- // TODO :NOT IMPLEMENTED
536+ public void setBlob (int parameterIndex , InputStream inputStream , long length )
537+ throws SQLException {
538+ throw new BigQueryJdbcSqlFeatureNotSupportedException ("setBlob is not supported." );
516539 }
517540
518541 @ Override
519- public void setNClob (int parameterIndex , Reader reader , long length ) {
520- // TODO :NOT IMPLEMENTED
542+ public void setNClob (int parameterIndex , Reader reader , long length ) throws SQLException {
543+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setNClob is not supported." );
521544 }
522545
523546 @ Override
524- public void setSQLXML (int parameterIndex , SQLXML xmlObject ) {
525- // TODO :NOT IMPLEMENTED
547+ public void setSQLXML (int parameterIndex , SQLXML xmlObject ) throws SQLException {
548+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setSQLXML is not supported." );
526549 }
527550
551+ /**
552+ * Note: BigQuery handles numeric scale and precision dynamically for NUMERIC (DECIMAL) and
553+ * BIGNUMERIC data types. The scaleOrLength parameter is ignored and delegates directly to {@link
554+ * #setObject(int, Object, int)}.
555+ */
528556 @ Override
529- public void setObject (int parameterIndex , Object x , int targetSqlType , int scaleOrLength ) {
530- // TODO(neenu) : IMPLEMENT?
557+ public void setObject (int parameterIndex , Object x , int targetSqlType , int scaleOrLength )
558+ throws SQLException {
559+ checkClosed ();
560+ setObject (parameterIndex , x , targetSqlType );
531561 }
532562
533563 @ Override
534- public void setAsciiStream (int parameterIndex , InputStream x , long length ) {
535- // TODO :NOT IMPLEMENTED
564+ public void setAsciiStream (int parameterIndex , InputStream x , long length ) throws SQLException {
565+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setAsciiStream is not supported." );
536566 }
537567
538568 @ Override
539- public void setBinaryStream (int parameterIndex , InputStream x , long length ) {
540- // TODO :NOT IMPLEMENTED
569+ public void setBinaryStream (int parameterIndex , InputStream x , long length ) throws SQLException {
570+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setBinaryStream is not supported." );
541571 }
542572
543573 @ Override
544- public void setCharacterStream (int parameterIndex , Reader reader , long length ) {
545- // TODO :NOT IMPLEMENTED
574+ public void setCharacterStream (int parameterIndex , Reader reader , long length )
575+ throws SQLException {
576+ throw new BigQueryJdbcSqlFeatureNotSupportedException ("setCharacterStream is not supported." );
546577 }
547578
548579 @ Override
549- public void setAsciiStream (int parameterIndex , InputStream x ) {
550- // TODO :NOT IMPLEMENTED
580+ public void setAsciiStream (int parameterIndex , InputStream x ) throws SQLException {
581+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setAsciiStream is not supported." );
551582 }
552583
553584 @ Override
554- public void setBinaryStream (int parameterIndex , InputStream x ) {
555- // TODO :NOT IMPLEMENTED
585+ public void setBinaryStream (int parameterIndex , InputStream x ) throws SQLException {
586+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setBinaryStream is not supported." );
556587 }
557588
558589 @ Override
559- public void setCharacterStream (int parameterIndex , Reader reader ) {
560- // TODO :NOT IMPLEMENTED
590+ public void setCharacterStream (int parameterIndex , Reader reader ) throws SQLException {
591+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setCharacterStream is not supported." );
561592 }
562593
563594 @ Override
564- public void setNCharacterStream (int parameterIndex , Reader value ) {
565- // TODO :NOT IMPLEMENTED
595+ public void setNCharacterStream (int parameterIndex , Reader value ) throws SQLException {
596+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setNCharacterStream is not supported." );
566597 }
567598
568599 @ Override
569- public void setClob (int parameterIndex , Reader reader ) {
570- // TODO :NOT IMPLEMENTED
600+ public void setClob (int parameterIndex , Reader reader ) throws SQLException {
601+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setClob is not supported." );
571602 }
572603
573604 @ Override
574- public void setBlob (int parameterIndex , InputStream inputStream ) {
575- // TODO :NOT IMPLEMENTED
605+ public void setBlob (int parameterIndex , InputStream inputStream ) throws SQLException {
606+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setBlob is not supported." );
576607 }
577608
578609 @ Override
579- public void setNClob (int parameterIndex , Reader reader ) {
580- // TODO :NOT IMPLEMENTED
610+ public void setNClob (int parameterIndex , Reader reader ) throws SQLException {
611+ throw new BigQueryJdbcSqlFeatureNotSupportedException ( "setNClob is not supported." );
581612 }
582613}
0 commit comments