Notes by voodoo
Displaying notes 81 - 90
Created by voodoo on November 25, 2010 00:15:37
Last update: November 25, 2010 00:15:37
PostgreSQL JDBC doc says:
Specifically deleting a row that contains a Large Object reference does not delete the Large Object. Deleting the Large Object is a separate operation that needs to be performed. .
In JDBC this can be done in two steps:
Delete the large object (call PostgreSQL function lo_unlink )
long oid = jdbcTemplate.queryForObject("select...
Delete the row in the referring table:
jdbcTemplate.update("delete from InventoryItem whe...
Created by voodoo on November 25, 2010 00:03:53
Last update: November 25, 2010 00:03:53
It seems that the JDBC standard way to create a BLOB is to call Connection.createBlob . However, this does not work for PostgreSQL (as of version 9.0-801 jdbc4):
Exception in thread "main" org.postgresql.util.PSQ...
The workaround is to call a PostgreSQL function to create the Blob, then use JDBC to update it:
Connection conn = jdbcTemplate.getDataSource().get...
Oracle Note: the Oracle way function to create an empty BLOB is EMPTY_BLOB() .
stmt.execute ("INSERT INTO my_blob_table VALUES ('...
Created by voodoo on November 24, 2010 23:43:29
Last update: November 24, 2010 23:43:29
Two of the three PreparedStatement.setBinaryStream methods are not implemented as of version 9.0-801 of the PostgreSQL JDBC driver.
Test program:
import java.io.*;
import java.sql.*;
pub...
Also note that setBinaryStream only works on a bytea column.
Created by voodoo on November 24, 2010 23:34:52
Last update: November 24, 2010 23:36:08
PostgreSQL provides two distinct ways to store binary data: Binary data can be stored in a table using the data type bytea . By using the Large Object feature which stores the binary data in a separate table in a special format and refers to that table by storing a value of type oid in your table. Different methods are used to access the BLOBs depending on which storage type you choose: To use the bytea data type you should use the getBytes() , setBytes() , getBinaryStream() , or setBinaryStream() methods. To use the Large Object functionality you can use either the LargeObject class provided by the PostgreSQL JDBC driver, or by using the getBLOB() and setBLOB() methods. Using setBinaryStream on an OID column yields...
Created by voodoo on November 22, 2010 19:47:18
Last update: November 22, 2010 19:47:43
Use the File::Spec module for portable file path separator (e.g., '/' for Unix/Linux, '\' for Windows):
# returns 'a/b/c' on Unix; 'a\b\c' on Windows
...
Or
# returns 'a/b/c' on Unix; 'a\b\c' on Windows
...
Created by voodoo on November 20, 2010 00:08:16
Last update: November 20, 2010 00:09:13
This error occurred when I try to use the Perl DBD module for PostgreSQL:
This is the solution:
Copy the file Pg.dll.manifest from perl/site/lib/auto/DBD/Pg/ to perl/bin/ .
Rename the manifest file perl.exe.manifest .
Created by voodoo on November 19, 2010 23:58:26
Last update: November 19, 2010 23:58:26
Download the PPD file from http://pgfoundry.org/projects/dbdpgppm/ .
Install the DBD module with ppm:
C:\tmp>ppm install DBD-Pg-2.10.0-Perl5.10.ppd
D...
Created by voodoo on November 02, 2010 16:07:49
Last update: November 02, 2010 16:11:56
From the command line I can start and stop Windows services with NET START service_name and NET STOP service_name . But the NET command does not give a way to find the service name. You need the sc command to get the service name, below are some examples:
List all running services:
sc query
List all services, running or not running (notice the space after =):
sc query type= service state= all
List all active drivers:
sc query type= driver
Find information about the "Indexing Service" (requires GNU grep):
sc query type= service state= all | grep -i index ...
Start the indexing service:
sc start CiSvc
Stop the indexing service:
sc stop CiSvc
Check the status of the indexing service:
sc query CiSvc
Created by voodoo on November 01, 2010 22:26:00
Last update: November 01, 2010 22:26:00
Some weirdness observed while updating BLOB with PostgreSQL JDBC driver: LOB position offset starts at 1 (not 0 as in IO input stream). When you call setBinaryStream(long pos) , pos must be greater than 0. I think this is JDBC standard behavior. When you write to a BLOB output stream, new contents overwrite existing contents. Old contents are not automatically truncated. If new content length is shorter than old contents, the old contents will remain after the position where new content ended. You can call Blob.truncate(long len) to truncate existing contents. However , there seems to be an discrepancy between the JDBC doc and PostgreSQL JDBC driver. The JDBC JavaDoc states that: Truncates the BLOB value that this Blob object represents to be len bytes...
Created by voodoo on October 15, 2010 15:48:57
Last update: October 15, 2010 15:49:20
Use the " -r sound:local " switch to redirect sound to the local client. However, for Fedora 13 the sound redirection does not work since it's looking for an OSS compatible audio device:
$ rdesktop -xl -r sound:local -f WinXPWs
Autose...
Bug 530431 was opened to bring support for pulseaudio to rdesktop. But the fix won't be available until Fedora 14. In the meanwhile, use padsp as a workaround:
padsp rdesktop -xl -r sound:local -f WinXPWs