Re: Large Objects
От | Nils O. Selåsdal |
---|---|
Тема | Re: Large Objects |
Дата | |
Msg-id | 01072720440300.28877@space.net обсуждение исходный текст |
Ответ на | Large Objects (Daniel Fisher <dfisher@vt.edu>) |
Список | pgsql-jdbc |
On Friday 27 July 2001 16:59, Daniel Fisher wrote: > I'm am attempting to make one of my Java servlets work with both MySQL & > Postgres. I'm having some trouble inserting a large object into the > database. I'm fairly certain that the problem is in my java code because I > wrote some quick PHP code and it worked fine. The main problem is I'm not > getting any errors, so I'm kinda stumped. The code appears to run fine, but > nothing is being inserted into the database. Any help would be appreciated. > > ----- Here is my Java source ----- > > // getConnection gives me a database connection > // image is a byte[] passed to this function > > Connection conn = null; > PreparedStatement pstmt = null; > > try { > > conn = getConnection(); > conn.setAutoCommit(false); > pstmt = conn.prepareStatement("INSERT INTO dfisher (image) VALUES > (?)"); pstmt.setBytes(1, image); > pstmt.executeUpdate(); > > } catch (Exception e) { > e.printStackTrace(); > } > finally { > try { if (pstmt != null) pstmt.close(); } catch (Exception e) { > e.printStackTrace(); } try { if (conn != null) conn.close(); } catch > (Exception e) { e.printStackTrace(); } } > } if you want to insert Large Objects, you need to use one of the setXXXStream of the statement, not setBytes.
В списке pgsql-jdbc по дате отправления: