IT-Academy icon

JAVA JDBC

IT-Academy | PRO | 04/21/22 05:29:50 PM UTC | 0 ⭐ | 1101 👁️ | Never ⏰ | []
Java |

1.18 KB

|

None

|

0 👍

/

0 👎

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
 */
package sk.stu.fiit;
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//import java.sql.*;
 
/**
 *
 * @author Administrator
 */
public class DB_Tester {
 
    private final String url = "jdbc:postgresql://localhost/testovacia";
    private final String pouzivatel = "postgres";
    private final String heslo = "20626mir.";
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        DB_Tester dbtest = new DB_Tester();
        dbtest.connect();
    }
 
    private void connect() {
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(url, pouzivatel, heslo);
            System.out.println("Gratulujem si sa pripojil...");
            conn.close();
        } catch (SQLException exSQL) {
            System.out.println("Nepripojil som sa - " + exSQL.getMessage());
        }
 
    }
 
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎