My program is provided below. The values are shifted as follows:
A 10
B 20
*************************
import java.io.*;
import java.sql.*;
import net.sourceforge.jtds.jdbc.*;
public class Bcp8Loader {
protected static final String msSql_DRIVER = "net.sourceforge.jtds.jdbc.Driver";
BCP con;
String table = "bcp8";
boolean tabSent;
public Bcp8Loader() {
String[] vals = new String[2];
int rowsInserted = 0;
try {
Class.forName( msSql_DRIVER );
con = (BCP) DriverManager.getConnection ("jdbc:jbcp:sqlserver://host/TREDS2;", "test", "test");
}
catch (Exception e) {
e.printStackTrace();
System.exit(8);
}
con.setDebug(3);
try {
vals[0] = "A";
vals[1] = ".01";
upd(vals);
vals[0] = "B";
vals[1] = ".02";
upd(vals);
con.close();
}
catch (Exception e) {
e.printStackTrace();
System.exit(8);
}
}
private int upd(String[] vals) {
int rowsInserted = 0;
try {
if (tabSent)
con.bcpInit();
else {
con.bcpInit(table);
tabSent = true;
}
con.bcpSetMSSQLHeader();
con.bcpSendRow(vals, vals.length);
rowsInserted = con.bcpBatch();
}
catch (SQLException e) {
e.printStackTrace();
System.exit(8);
}
catch (IOException e) {
e.printStackTrace();
System.exit(8);
}
System.out.println("rowsInserted=" + rowsInserted);
return rowsInserted;
}
public static void main(String[] args) {
new Bcp8Loader();
}
}
Logged In: NO
I forgot to mention the table is
field1 char(1),
field2 decimal(5,3)
Logged In: NO
The lack of support for Decimals and Numerics is a known limitation and will be addressed with later releases.