Hmm jeg bruger lignende metode hvor det virker fint. Ligger driveren i
din classpath?
Hvad siger din stack trace?
--
Regards, Frank
(remove nospam. from domain for mailing)
Henrik Hedegaard wrote:
> Jeg har et problem med at connecte til min MySQL database via interfacet i
> JAVA.
>
> Af en eller anden årsag kan java ikke loade min JDBC driver. Hvorfor ikke?
> Jeg har vedhæftet min kode.
>
> /Henrik
>
>
> ---------- dbms.java ----------
>
> import java.sql.*;
> import java.util.*;
>
>
> public class dbms
> {
> private static final String DB = "mimerdesk";
> private static final String URL =
> "jdbc:mysql://
www.studenterradio.au.dk:3306/";
> private static final String ACCOUNT = "xxxxx";
> private static final String PASS = "xxx";
> private static final String DRIVER = "org.gjt.mm.mysql.Driver";
> private String TestStatement = "SELECT * FORM profileparts";
>
>
> public dbms()
> {
> if( dbAccess() )
> System.out.print("HURRA - DER ER FORBINDELSE!!!");
> }
>
>
> public boolean dbAccess()
> {
> try
> {
> Properties props = new Properties();
> props.setProperty("user", ACCOUNT);
> props.setProperty("password", PASS);
>
> Class.forName(DRIVER).newInstance();
> Connection con = DriverManager.getConnection(URL+DB,props);
> return true;
> }
> catch(Exception E)
> {
> System.err.println("Unable to load driver");
> E.printStackTrace();
> return false;
> }
> }
>
> }
>
>