IMPORTANT NOTICE This post was published in 2007 and some code was used to interact with databases which had no JDBC connector. It is a very bad practice and unrecommended to send SQL statements directly to a database Such a simple thing as replacing an apostrophe with an escape character from a string sometimes can become a very tedious process, more if you’re using String’s replaceAll(…) function. Replacing apostrophes from Strings may be very useful when creating Statements to pass to an SQL database, preventing SQL injection. Many may say that using PreparedStatements is easier and safer, but in many […]

Replacing Apostrophes from Strings // Cleaning String to pass them ...

Today I’ll show you an easy way to automate your database backup dumps with a java application that runs on the background. This simple app will generate a backup of your database and will name it with today’s date. It’s not really the java program interacting with the database, but the app interacting with the command line program pg_dump. The thing is quite simple. First we generate a filename with today’s date. Then we check if the file exists. Finally we call the pg_dump with the appropriate parameters and the backup is generated [crayon-5a931304713dc756123595/] To run the above programs you […]

Java App for PostgreSQL scheduled backups using pg_dump (Windows only)