1313import java .math .BigDecimal ;
1414import java .net .MalformedURLException ;
1515import java .net .URL ;
16+ import java .nio .ByteBuffer ;
1617import java .sql .Array ;
1718import java .sql .Blob ;
1819import java .sql .Clob ;
@@ -1506,14 +1507,35 @@ else if(blobFiles.length < index)
15061507 }
15071508 }
15081509
1510+ private static byte [] floatArrayToByteArray (Float [] floats ) {
1511+ ByteBuffer buffer = ByteBuffer .allocate (floats .length * Float .BYTES );
1512+
1513+ for (Float f : floats ) {
1514+ if (f != null ) {
1515+ buffer .putFloat (f );
1516+ } else {
1517+ buffer .putFloat (0.0f );
1518+ }
1519+ }
1520+ return buffer .array ();
1521+ }
1522+
15091523 public void setEmbedding (int index , Float [] value ) throws SQLException {
1510- Array sqlArray = con .createArrayOf ("float4" , value );
1524+ byte [] bytes = null ;
1525+ Array sqlArray = null ;
1526+ if (con .getDBMS ().getId () == GXDBMS .DBMS_POSTGRESQL )
1527+ sqlArray = con .createArrayOf ("float4" , value );
1528+ else
1529+ bytes = floatArrayToByteArray (value );
15111530 if (DEBUG )
15121531 {
15131532 log (GXDBDebug .LOG_MAX , "setEmbedding - index : " + index );
15141533 try
15151534 {
1516- stmt .setArray (index , sqlArray );
1535+ if (con .getDBMS ().getId () == GXDBMS .DBMS_POSTGRESQL )
1536+ stmt .setArray (index , sqlArray );
1537+ else
1538+ stmt .setBytes (index , bytes );
15171539 }
15181540 catch (SQLException sqlException )
15191541 {
@@ -1523,7 +1545,10 @@ public void setEmbedding(int index, Float[] value) throws SQLException{
15231545 }
15241546 else
15251547 {
1526- stmt .setArray (index , sqlArray );
1548+ if (con .getDBMS ().getId () == GXDBMS .DBMS_POSTGRESQL )
1549+ stmt .setArray (index , sqlArray );
1550+ else
1551+ stmt .setBytes (index , bytes );
15271552 }
15281553 }
15291554
0 commit comments