Kan ikke oprette forbindelse til db
Det skal siges at det har fungeret før, men driller igen :FORBINDELSE TIL DB:
public class ConnectToDatabase
{
public static Connection con= null;
public static Statement stmt = null;
//Opret forbindelse til MySQL database i konstruktør
public ConnectToDatabase () throws Exception
{
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/bilreservedele","root","touel");
//con.setAutoCommit(false);
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
System.out.println( e.getMessage());
}
//Check om forb er gyldig....
if (con == null)
{
System.err.println ("FEJL ! Kunne ikke oprette forbindelse");
}
}
public Connection getCon ()
{
return con;
}
public void setCon (Connection con)
{
ConnectToDatabase.con= con;
}
%
