私のJavaコードは次のとおりです。
conn = DriverManager.getConnection(url, "user", "password"); // line 1
stm = conn.createStatement(); // line 2
stm.execute("CREATE TEXT TABLE someTableName("NLID" VARCHAR(20),
"Scheduled.Primary.Scripting.Code" VARCHAR(20), "Scheduled.Site" VARCHAR(20),
"Scheduled.Location.Long.Name" VARCHAR(20),
"primary_key_1644" int PRIMARY KEY)"); // line 3
stm.execute("SET TABLE someTableName SOURCE
"/some.csv;ignore_first=true;all_quoted=true;shutdown=true""); // line 4
hsqldb にリンクされている CSV は次のとおりです。
NLID,Scheduled.Primary.Scripting.Code,Scheduled.Site,Scheduled.Location.Long.Name,primary_key_1644
100,INMRSB,Shopping,Shopping General-Banner-728x90-INMRSB-I,1
100002,MSVT08,MSN Video,msnbc.com-TODAYshow.com Special Sponsorships 8-Streaming Media-300x60-MSVT08-S,2
100004,MSV10T,MSN Video,msnbc.com-TODAYshow.com Special Sponsorships 10-Streaming Media-300x60-MSV10T-S,3
4 行目で以下の例外が発生します。
java.sql.SQLException: bad TEXT table source file - line number: 1196 java.lang.NumberFormatException: For input string: "Body Connection-Banner-728x90-HEAMBA-S" in statement [SET TABLE someTableName SOURCE "/some.csv;ignore_first=true;all_quoted=true;shutdown=true"]
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
at java.lang.NumberFormatException: For input string: "Body Connection-Banner-728x90-HEAMBA-S"
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.TextTable.connect(Unknown Source)
at org.hsqldb.TextTable.openCache(Unknown Source)
at org.hsqldb.TextTable.setDataSource(Unknown Source)
at org.hsqldb.StatementCommand.getResult(Unknown Source)
at org.hsqldb.StatementCommand.execute(Unknown Source)
at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
at org.hsqldb.Session.executeDirectStatement(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 6 more
Caused by: java.lang.NumberFormatException: For input string: "Body Connection-Banner-728x90-HEAMBA-S"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.hsqldb.rowio.RowInputText.readInteger(Unknown Source)
at org.hsqldb.rowio.RowInputBase.readData(Unknown Source)
at org.hsqldb.rowio.RowInputText.readData(Unknown Source)
at org.hsqldb.rowio.RowInputBase.readData(Unknown Source)
at org.hsqldb.rowio.RowInputText.readData(Unknown Source)
at org.hsqldb.RowAVLDiskData.getRowData(Unknown Source)
at org.hsqldb.persist.RowStoreAVLDiskData.get(Unknown Source)
... 14 more
どんな助けもかなりのものです。
EDITED : Hsqldb は、VARCHAR として定義されている列の読み取り中に NumberFormatException をスローします!!!
MODIFIED :列の値の 1 つにカンマが含まれているため、例外が発生します"Mind, Body Connection-Banner-728x90-HEAMBA-S"
。hsqldb は csv をテーブルとして読み取るため、追加のコンマは hsql によって追加の列として解釈されます。これを回避する方法を教えてもらえますか?