data comes in a string, inserting into postgresql with java, what's most efficient way to break up the data? -
i writing program in java uses jdbc driver postgresql. using api when called, returns data in string so:
id=-870229851 date = finished-20130501 15:13:07-20130502 15:13:07 open=-1.0 high=-1.0 low=-1.0 close=-1.0 volume=-1 count=-1 wap=-1.0 hasgaps=false
most of these names column in postgresql db (and can make of them column if necessary), wondering efficient way insert postgresql?
before write function parse each title / value, i'm hoping postgresql has way of handling data efficiently.
can please shed light?
my postgresql version 9.2 , java 1.7
postrgre doesn't have way natively (that know of anyway), however, can use java's string tokenizer this:
stringtokenizer st = new stringtokenizer(sourcestring, "= "); while(st.hasmoretokens()) { string key = st.nexttoken(); string valuse = st.nexttoken(); // keys , values (i.e. build , execute insert statements. }
where sourcestring data string. delimit string based on both equals sign , space between name value pairs. assuming no spaces occur in name or values in string. if do, going have regex magic on string before tokenizing it, depending on can occur on left , right hand side of equals sign.
then can generate insert statement strings executed database engine.
Comments
Post a Comment