hi,
i have tried to reproduce your problem on 6.2.2, but i was unsuccessfull...i paste the java test code here, do you think it models your problem? what should we change to model more precisely your environment/situation
what kind of database are you using behind jchem?
what is the type of the column AccNo?
regards.kirk
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import chemaxon.jchem.db.DatabaseProperties;
import chemaxon.jchem.db.StructureTableOptions;
import chemaxon.jchem.db.UpdateHandler;
import chemaxon.util.ConnectionHandler;
import chemaxon.util.DotfileUtil;
public class UHAdditionColumnsProblem {
private static final String TABLE_NAME = "test_adf";
private static ConnectionHandler ch;
@BeforeClass
public static void beforeClass() throws SQLException, Exception {
try {
ch = new ConnectionHandler();
File f = DotfileUtil.getDotFile(".jchem");
Properties p = new Properties();
p.load(new FileInputStream(f));
ch.loadValuesFromProperties(p);
ch.connectToDatabase();
if (!DatabaseProperties.propertyTableExists(ch)) {
DatabaseProperties.createPropertyTable(ch);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@AfterClass
public static void afterClass() {
try {
ch.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
@Test
public void testWithAdditionalColumn() throws Exception{
if (UpdateHandler.isStructureTable(ch, TABLE_NAME)) {
UpdateHandler.dropStructureTable(ch, TABLE_NAME);
}
String createTableTail = ", AccNo int";
StructureTableOptions tableOptions = new StructureTableOptions(TABLE_NAME);
tableOptions.setExtraColumnDefinitions(createTableTail);
System.out.println(ch);
UpdateHandler.createStructureTable(ch, tableOptions);
UpdateHandler uh = new UpdateHandler(ch, UpdateHandler.INSERT, TABLE_NAME, "AccNo");
uh.setStructure("C1CCC1");
int shouldBe = 0;
if (shouldBe > 0) {
uh.setValueForAdditionalColumn(1, shouldBe);
}
uh.execute();
PreparedStatement pstmt =
ch.getConnection().prepareStatement(
"select cd_structure,AccNo from " + tableOptions.getName() + "");
try {
ResultSet rs = pstmt.executeQuery();
try {
Assert.assertTrue(rs.next());
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
if (shouldBe > 0) {
assertEquals(shouldBe, rs.getInt(2));
} else {
assertEquals(0, rs.getInt(2));
}
Assert.assertFalse(rs.next());
} finally {
rs.close();
}
} finally {
pstmt.close();
}
}
}