Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Ironmax
    Registrato dal
    Dec 2008
    Messaggi
    1,026

    Problemi di connessione a postgresql

    Salve.
    Sto tentando di connettermi a postgresql con questa classe:
    codice:
    import java.sql.Connection;
    import java.sql.DriverManager;
    
    public class Main {
    
        public static void main(String args[]) {
            Connection con = null;
            try {
                Class.forName("org.postgresql.Driver");
                con = DriverManager.getConnection(
                        "jdbc:postgresql://localhost:5432/", "max",
                        "root");
            } catch (Exception e) {
                e.printStackTrace();
                System.err.println(e.getClass().getName() + ": " + e.getMessage());
                System.exit(0);
            }
            System.out.println("Opened database successfully");
        }
    
    }
    Ho importato il connettore:
    postgresql-9.4.1208.jre6

    La console mi da il seguente errore:
    codice:
    org.postgresql.util.PSQLException: FATALE: autenticazione con password fallita per l'utente "max"
        at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:433)
        at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:208)
        at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
        at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215)
        at org.postgresql.Driver.makeConnection(Driver.java:406)
        at org.postgresql.Driver.connect(Driver.java:274)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at java.sql.DriverManager.getConnection(Unknown Source)
        at Main.main(Main.java:10)
    org.postgresql.util.PSQLException: FATALE: autenticazione con password fallita per l'utente "max"
    Grazie

  2. #2
    Utente di HTML.it L'avatar di Ironmax
    Registrato dal
    Dec 2008
    Messaggi
    1,026
    Ragazzi tutto a posto:
    codice:
    import java.sql.Connection;
    import java.sql.DriverManager;
    
    public class Main {
    
        public static void main(String args[]) {
            Connection con = null;
            try {
                Class.forName("org.postgresql.Driver");
                con = DriverManager.getConnection(
                        "jdbc:postgresql://localhost:5432/corso", "postgres",
                        "root");
            } catch (Exception e) {
                e.printStackTrace();
                System.err.println(e.getClass().getName() + ": " + e.getMessage());
                System.exit(0);
            }
            System.out.println("Opened database successfully");
        }
    
    }
    Modificato utente in "postgres"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.