java - JDBC preparedstatement convert control character to question mark -
a problem occurring when inserting control character(/u0096)
. preparedstatement
converting "?".
occurs in cases.
it happens in these 2 cases:
"– varmer å få prisen" "hestnes – et industrieventyr"
in other uses of character nothing , insert "-" in database.
i tried convert normal "-", same results.
preparedstatement prepstmt = makeinsertnewsitemstatement(); ( 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 app_feededitor_newsitems" + "(title, ingress, url, feed_id, published, source, picture_url)" + "values (?, ?, ?, ?, ?, ?, ?)"; return makestatement( sql ); }
the character in item.title()
Comments
Post a Comment