插入control character(/u0096)
时出现问题。 preparedstatement
正在将其转换为"?".
但它只在某些情况下发生。
在这两种情况下都会发生:
"– Varmer å få prisen"
"Hestnes – et industrieventyr"
在此角色的所有其他用途中,它不执行任何操作,并在数据库中插入“ - ”。
我尝试将其转换为正常“ - ”,但结果相同。
PreparedStatement prepStmt = makeInsertNewsItemStatement();
for ( NewsItem item : uniqueItems ) {
try {
if ( !resultSet.next() ) {
prepStmt.setString( 1, item.getTitle() );
prepStmt.setString( 2, item.getDescription() );
prepStmt.setString( 3, item.getLink() );
prepStmt.setInt( 4, item.getFeedId() );
prepStmt.setTimestamp(
5, item.getPubDate() == null ?
new Timestamp(new Date().getTime()) :
new Timestamp( item.getPubDate().getTime() ) );
prepStmt.setString( 6, item.getAuthor() );
prepStmt.setString( 7, company.getCompanyId() == 20 ? null : item.getPictureUrl() );
prepStmt.executeUpdate();
}
} catch ( SQLException ex ) {
Logger.getLogger( MasterDbController.class.getName() ).log( Level.SEVERE, null, ex );
continue;
}
...
private PreparedStatement makeStatement( String sql ) {
PreparedStatement prepStmt = null;
try {
prepStmt = companyConnection.prepareStatement( sql );
} catch ( SQLException ex ) {
Logger.getLogger( CompanyDbController.class.getName() ).log( Level.SEVERE, null, ex );
}
return prepStmt;
}
private PreparedStatement makeInsertNewsItemStatement() {
String sql = "INSERT INTO App_FeedEditor_NewsItems"
+ "(title, ingress, url, feed_id, published, source, picture_url)"
+ "VALUES (?, ?, ?, ?, ?, ?, ?)";
return makeStatement( sql );
}
该字符位于item.title()
中