add argNull, fix column size metadata setup

This commit is contained in:
Jörg Prante 2022-06-24 17:19:03 +02:00
parent 9c1a331d6b
commit 46eed697d4
5 changed files with 43 additions and 42 deletions

View file

@ -10,9 +10,7 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
@ -237,15 +235,14 @@ public class DatabaseImpl implements Database {
int cols = rsmd.getColumnCount();
while (rs.next()) {
String name = "";
Integer size = 0;
int size = 0;
for (int i = 1; i <= cols; i++) {
String label = rsmd.getColumnName(i);
Object v = rs.getObject(i);
if (label.equals("COLUMN_NAME")) {
name = (String) v;
if ("COLUMN_NAME".equalsIgnoreCase(label)) {
name = rs.getString(i);
}
if (label.equals("COLUMN_SIZE")) {
size = (Integer) v;
if ("COLUMN_SIZE".equalsIgnoreCase(label)) {
size = rs.getBigDecimal(i).intValue();
}
}
map.put(name, size);

View file

@ -71,6 +71,8 @@ public interface SqlInsert {
SqlInsert argClobReader(String argName, Reader arg);
SqlInsert argNull(String argName);
SqlInsert withArgs(SqlArgs args);
SqlInsert apply(Apply apply);

View file

@ -1,5 +1,6 @@
package org.xbib.jdbc.query;
import java.sql.Types;
import org.xbib.jdbc.query.util.DebugSql;
import org.xbib.jdbc.query.util.InternalStringReader;
import org.xbib.jdbc.query.util.Metric;
@ -159,7 +160,6 @@ public class SqlInsertImpl implements SqlInsert {
return positionalArg(adaptor.nullLocalDate(arg));
}
@Override
public SqlInsert argDateNowPerApp() {
return positionalArg(adaptor.nullDate(options.currentDate()));
@ -179,7 +179,6 @@ public class SqlInsertImpl implements SqlInsert {
}
@Override
public SqlInsert argDateNowPerDb( String argName) {
if (options.useDatePerAppOnly()) {
return namedArg(argName, adaptor.nullDate(options.currentDate()));
@ -188,53 +187,49 @@ public class SqlInsertImpl implements SqlInsert {
}
@Override
public SqlInsert argBlobBytes(byte[] arg) {
return positionalArg(adaptor.nullBytes(arg));
}
@Override
public SqlInsert argBlobBytes( String argName, byte[] arg) {
return namedArg(argName, adaptor.nullBytes(arg));
}
@Override
public SqlInsert argBlobStream(InputStream arg) {
return positionalArg(adaptor.nullInputStream(arg));
}
@Override
public SqlInsert argBlobStream( String argName, InputStream arg) {
return namedArg(argName, adaptor.nullInputStream(arg));
}
@Override
public SqlInsert argClobString(String arg) {
return positionalArg(adaptor.nullClobReader(arg == null ? null : new InternalStringReader(arg)));
}
@Override
public SqlInsert argClobString( String argName, String arg) {
return namedArg(argName, adaptor.nullClobReader(arg == null ? null : new InternalStringReader(arg)));
}
@Override
public SqlInsert argClobReader(Reader arg) {
return positionalArg(adaptor.nullClobReader(arg));
}
@Override
public SqlInsert argClobReader( String argName, Reader arg) {
return namedArg(argName, adaptor.nullClobReader(arg));
}
@Override
public SqlInsert argNull(String argName) {
return namedArg(argName, new SqlNull(Types.VARCHAR));
}
@Override
public SqlInsert withArgs(SqlArgs args) {

View file

@ -71,6 +71,8 @@ public interface SqlUpdate {
SqlUpdate argClobReader(String argName, Reader arg);
SqlUpdate argNull(String argName);
SqlUpdate withArgs(SqlArgs args);
SqlUpdate apply(Apply apply);

View file

@ -1,5 +1,6 @@
package org.xbib.jdbc.query;
import java.sql.Types;
import org.xbib.jdbc.query.util.DebugSql;
import org.xbib.jdbc.query.util.InternalStringReader;
import org.xbib.jdbc.query.util.Metric;
@ -229,6 +230,10 @@ public class SqlUpdateImpl implements SqlUpdate {
return namedArg(argName, adaptor.nullClobReader(arg));
}
@Override
public SqlUpdate argNull(String argName) {
return namedArg(argName, new SqlNull(Types.VARCHAR));
}
@Override
public SqlUpdate withArgs(SqlArgs args) {