Hirdetés

Új hozzászólás Aktív témák

  • gaben

    aktív tag

    Feltettem egy MYSQL-t a gépemre, ill. a XAMPP-ben már benne volt.Tehát localhost-on ban,böngészőben el is érem phpMyadmin-on keresztül.
    De sehogy nem sikerül csatlakoznom.Mi lehet a gond?

    public class Sql
    {
    public static void main (String[] args)
    {
    Connection conn = null;

    try
    {
    String userName = "root";
    String password = "123";
    String url = "jdbc:mysql://localhost/jatekos";
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    conn = DriverManager.getConnection (url, userName, password);
    System.out.println ("Database connection established");
    }
    catch (Exception e)
    {
    System.err.println ("Cannot connect to database server");
    }
    finally
    {
    if (conn != null)
    {
    try
    {
    conn.close ();
    System.out.println ("Database connection terminated");
    }
    catch (Exception e) { /* ignore close errors */ }
    }
    }
    }
    }

Új hozzászólás Aktív témák