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

@ -49,27 +49,29 @@ public interface SqlInsert {
SqlInsert argDateNowPerApp();
SqlInsert argDateNowPerApp( String argName);
SqlInsert argDateNowPerApp(String argName);
SqlInsert argDateNowPerDb();
SqlInsert argDateNowPerDb( String argName);
SqlInsert argDateNowPerDb(String argName);
SqlInsert argBlobBytes(byte[] arg);
SqlInsert argBlobBytes( String argName, byte[] arg);
SqlInsert argBlobBytes(String argName, byte[] arg);
SqlInsert argBlobStream(InputStream arg);
SqlInsert argBlobStream( String argName, InputStream arg);
SqlInsert argBlobStream(String argName, InputStream arg);
SqlInsert argClobString(String arg);
SqlInsert argClobString( String argName, String arg);
SqlInsert argClobString(String argName, String arg);
SqlInsert argClobReader(Reader arg);
SqlInsert argClobReader( String argName, Reader arg);
SqlInsert argClobReader(String argName, Reader arg);
SqlInsert argNull(String argName);
SqlInsert withArgs(SqlArgs args);

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

@ -13,63 +13,65 @@ public interface SqlUpdate {
SqlUpdate argBoolean(Boolean arg);
SqlUpdate argBoolean( String argName, Boolean arg);
SqlUpdate argBoolean(String argName, Boolean arg);
SqlUpdate argInteger(Integer arg);
SqlUpdate argInteger( String argName, Integer arg);
SqlUpdate argInteger(String argName, Integer arg);
SqlUpdate argLong(Long arg);
SqlUpdate argLong( String argName, Long arg);
SqlUpdate argLong(String argName, Long arg);
SqlUpdate argFloat(Float arg);
SqlUpdate argFloat( String argName, Float arg);
SqlUpdate argFloat(String argName, Float arg);
SqlUpdate argDouble(Double arg);
SqlUpdate argDouble( String argName, Double arg);
SqlUpdate argDouble(String argName, Double arg);
SqlUpdate argBigDecimal(BigDecimal arg);
SqlUpdate argBigDecimal( String argName, BigDecimal arg);
SqlUpdate argBigDecimal(String argName, BigDecimal arg);
SqlUpdate argString(String arg);
SqlUpdate argString( String argName, String arg);
SqlUpdate argString(String argName, String arg);
SqlUpdate argDate(LocalDateTime arg);
SqlUpdate argDate( String argName, LocalDateTime arg);
SqlUpdate argDate(String argName, LocalDateTime arg);
SqlUpdate argLocalDate(LocalDate arg);
SqlUpdate argLocalDate( String argName, LocalDate arg);
SqlUpdate argLocalDate(String argName, LocalDate arg);
SqlUpdate argDateNowPerApp();
SqlUpdate argDateNowPerApp( String argName);
SqlUpdate argDateNowPerApp(String argName);
SqlUpdate argDateNowPerDb();
SqlUpdate argDateNowPerDb( String argName);
SqlUpdate argDateNowPerDb(String argName);
SqlUpdate argBlobBytes(byte[] arg);
SqlUpdate argBlobBytes( String argName, byte[] arg);
SqlUpdate argBlobBytes(String argName, byte[] arg);
SqlUpdate argBlobStream(InputStream arg);
SqlUpdate argBlobStream( String argName, InputStream arg);
SqlUpdate argBlobStream(String argName, InputStream arg);
SqlUpdate argClobString(String arg);
SqlUpdate argClobString( String argName, String arg);
SqlUpdate argClobString(String argName, String arg);
SqlUpdate argClobReader(Reader arg);
SqlUpdate argClobReader( String argName, Reader arg);
SqlUpdate argClobReader(String argName, Reader arg);
SqlUpdate argNull(String argName);
SqlUpdate withArgs(SqlArgs args);

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) {