Hooh! So HAPPY!!! Finally, got it resolved for PostgreSQL 9.2 in Windows Environment
Inside the pg_hba.conf that is inside the folder C:\Program Files\PostGreSQL\9.2\data, navigate to the section titled "# IPv4 ...", and add this:
# IPv4 local connections:
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
For the second row, which is originally there with md5 authentication, make it trust also.
This solution is referenced to: http://www.postgresql.org/docs/9.2/static/auth-methods.html
For more details about any security issue, if your scenario is not for localhost connection. For my case, am trying to connect using localhost.
The following is a sample code used in Java:
import java.sql.*;
import java.util.*;
public class PGSample
{
public static void main(String[] args)
{
Connection connection = null;
try
{
// the postgresql driver string
Class.forName("org.postgresql.Driver");
// the postgresql url
String url = "jdbc:postgresql://localhost:5432/TestDB";
// get the postgresql database connection
connection = DriverManager.getConnection(url,"pguser", "");
// now do whatever you want to do with the connection
// ...
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
System.exit(1);
}
catch (SQLException e)
{
e.printStackTrace();
System.exit(2);
}
}
}
Note: Replace the database TestDB with the name of the DB in your pc or server. Also, replace "pguser" with the user id in your own server.
This blog captures some of the thoughts, ideas and things that am learning, researching and exploring on areas such as: Project Management, Software Development, Open Source, etc. Feel free to feedback or comment :)
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Saturday, May 18, 2013
Friday, April 26, 2013
Java + PostgreSQL
http://zetcode.com/db/postgresqljavatutorial/
http://www.java-samples.com/showtutorial.php?tutorialid=202
http://alvinalexander.com/blog/post/jdbc/sample-java-jdbc-program-connect-database
Configuring: http://jdbc.postgresql.org/documentation/head/setup.html
Download Driver: http://jdbc.postgresql.org/download.html
Checking JDBC: http://stackoverflow.com/questions/4215742/how-to-test-if-jdbc-driver-is-installed-correctly-and-if-the-db-can-be-connected
http://www.java-samples.com/showtutorial.php?tutorialid=202
http://alvinalexander.com/blog/post/jdbc/sample-java-jdbc-program-connect-database
Configuring: http://jdbc.postgresql.org/documentation/head/setup.html
Download Driver: http://jdbc.postgresql.org/download.html
Checking JDBC: http://stackoverflow.com/questions/4215742/how-to-test-if-jdbc-driver-is-installed-correctly-and-if-the-db-can-be-connected
Wednesday, April 03, 2013
Unicode and Chinese Characters in Java - Reference
The following are some reference points for above subject ...
Currently, am still busy to explore further ... so to keep my self some convenience for the research later :)
Added on 26 Apr
http://javarevisited.blogspot.com/2012/01/get-set-default-character-encoding.html
http://stackoverflow.com/questions/2622911/fix-string-encoding-in-java
http://www.tutorialspoint.com/java/java_string_getbytes.htm
http://exampledepot.8waytrips.com/egs/java.nio.charset/ConvertChar.html
http://examples.javacodegeeks.com/core-java/nio/charbuffer/convert-between-character-set-encodings-with-charbuffer/
---------------------------------------------------------------------------------------------------------------
http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html
http://docs.oracle.com/javase/7/docs/api/java/io/InputStreamReader.html
http://www.velocityreviews.com/forums/t592855-how-to-display-input-write-chinese-text-in-java.html
http://stackoverflow.com/questions/766361/how-to-save-chinese-characters-to-file-with-java
http://www.b-t.asia/chinese/prog-java.php
https://forums.oracle.com/forums/thread.jspa?messageID=9949628�
http://users.erols.com/eepeter/chinesecomputing/programming/java.html
http://stackoverflow.com/questions/8873121/reading-chinese-characters-into-a-string-from-a-byte-buffer
http://www.mkyong.com/java/java-convert-chinese-character-to-unicode-with-native2ascii/
http://www.mandarintools.com/javaconverter.html
Currently, am still busy to explore further ... so to keep my self some convenience for the research later :)
Added on 26 Apr
http://javarevisited.blogspot.com/2012/01/get-set-default-character-encoding.html
http://stackoverflow.com/questions/2622911/fix-string-encoding-in-java
http://www.tutorialspoint.com/java/java_string_getbytes.htm
http://exampledepot.8waytrips.com/egs/java.nio.charset/ConvertChar.html
http://examples.javacodegeeks.com/core-java/nio/charbuffer/convert-between-character-set-encodings-with-charbuffer/
---------------------------------------------------------------------------------------------------------------
http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html
http://docs.oracle.com/javase/7/docs/api/java/io/InputStreamReader.html
http://www.velocityreviews.com/forums/t592855-how-to-display-input-write-chinese-text-in-java.html
http://stackoverflow.com/questions/766361/how-to-save-chinese-characters-to-file-with-java
http://www.b-t.asia/chinese/prog-java.php
https://forums.oracle.com/forums/thread.jspa?messageID=9949628�
http://users.erols.com/eepeter/chinesecomputing/programming/java.html
http://stackoverflow.com/questions/8873121/reading-chinese-characters-into-a-string-from-a-byte-buffer
http://www.mkyong.com/java/java-convert-chinese-character-to-unicode-with-native2ascii/
http://www.mandarintools.com/javaconverter.html
Subscribe to:
Posts (Atom)
Converting a Physical Linux to Virtual
Hmm ... I have done a lot of work on my Linux Lubuntu 15.10 with PHP and PostgreSQL and a few other things ... it is quite time-consuming to...
-
I have got the book: Crucial Confrontation ! It is really a great book. After reading it, I learned a very valuable lesson on how to deal wi...
-
Here are something to read about PM KPI: KPI explained When we want to create KPIs for PM, we need to use the CSC (Critical Success Criter...
-
This link shows why project management methodology is important. It also leads to the complete methodology of Tasmanian State Government .