Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Connect java with PostgreSQL using SSPI authentication.

  1. #1
    Junior Member
    Join Date
    Aug 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Connect java with PostgreSQL using SSPI authentication.

    Connect java with PostgreSQL using SSPI authentication.

    Installed PostgreSQL using SSPI authentication (version: 16.3). I am able to connect using pgAdmin4 tool. I'm attempting to connect java with PostgreSQL.

    I modified the pg_hba.conf to enable SSPI connection.
    host all dbadmin 172.16.8.212/32 sspi map=SSPI
    host all dbadmin ::1/128 sspi map=SSPI

    The following JAR files are being used for Java connectivity:
    1. postgresql.jdbc3.jar (version 42.7.2)
    2. waffle-jna-1.9.0 (version 1.9.0)
    3. jna-4.5.2 (version 4.5.2)
    4. jna-platform-4.5.2 (version 4.5.2 (b0))

    Url used for connectivity:
    url = "jdbc:postgresql://172.16.8.212:5432/postgres?gsslib=sspi&sspiServiceClass=POSTGRES";
    Connection conn = DriverManager.getConnection(url, props) //where props have only username.

    Exception I got:
    org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
    at org.postgresql.Driver.connect(Driver.java:320)
    at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
    at PostgresSSPIExample.main(PostgresSSPIExample.java: 11)
    Caused by: java.lang.RuntimeException: NTDSAPI DsMakeSpn call failed with 87
    at org.postgresql.sspi.NTDSAPIWrapper.DsMakeSpn(NTDSA PIWrapper.java:48)
    at org.postgresql.sspi.SSPIClient.makeSPN(SSPIClient. java:134)
    at org.postgresql.sspi.SSPIClient.startSSPI(SSPIClien t.java:180)
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAut hentication(ConnectionFactoryImpl.java:811)
    at org.postgresql.core.v3.ConnectionFactoryImpl.tryCo nnect(ConnectionFactoryImpl.java:203)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openC onnectionImpl(ConnectionFactoryImpl.java:258)
    at org.postgresql.core.ConnectionFactory.openConnecti on(ConnectionFactory.java:54)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnecti on.java:263)
    at org.postgresql.Driver.makeConnection(Driver.java:4 44)
    at org.postgresql.Driver.connect(Driver.java:297)
    ... 3 more

    Is this driver problem or setup problem?

    I used latest driver version also. But nothing seems to work.

  2. #2
    Junior Member
    Join Date
    Oct 2024
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Connect java with PostgreSQL using SSPI authentication.

    Connecting Java to PostgreSQL using SSPI authentication is quite useful. It is important to ensure that the pg_hba.conf file is configured correctly and that all the necessary JAR files are present in the project to facilitate a successful connection.geometry dash scratch
    Last edited by SarahCNash; October 4th, 2024 at 03:41 AM.

Similar Threads

  1. Java code to open url with basic authentication
    By surya119 in forum Java Networking
    Replies: 1
    Last Post: April 17th, 2021, 08:03 AM
  2. Role based Authentication using java jersey
    By dude001 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 29th, 2014, 09:21 AM
  3. Replies: 4
    Last Post: September 22nd, 2013, 01:43 PM
  4. Java WebApps & CAC/smart card authentication?
    By tinker123 in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: April 25th, 2013, 03:00 PM
  5. Need help to connect to PostgreSql
    By stab in forum JDBC & Databases
    Replies: 3
    Last Post: June 3rd, 2011, 09:01 AM

Tags for this Thread