This is a servlet code example for jdbc using the mm driver. //////////////// String DB_NAME = "database"; String DB_HOST = "localhost"; String DB_USER = "username"; String DB_PASS = password; String DB_DRIVER = "org.gjt.mm.mysql.Driver"; String DB_CONNECTION = "jdbc:mysql://" + DB_HOST + "/" + DB_NAME + "?user=" + DB_USER + "&password=" + DB_PASS;
try { Class.forName(DB_DRIVER); conn = DriverManager.getConnection(DB_CONNECTION); out.println("<BR><BR>JDBC Connection succeeded."); } catch (Exception e) { out.println(e.getMessage()); } //////////////// Ken Chris Stewart wrote: > > I'm trying to make a connection from a java app to a MySQL database I've > created on my local PC. How can I tell the app where to look for the > existing database? > > Code I'm working with: > > Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); > Connection con = > DriverManager.getConnection("jdbc:odbc:Testing@localhost:3306", "< my > username >", "< my pass >"); > System.out.println("Connection Made."); > > As you can tell from this, my database is named "Testing". All I'm > trying to do right now is get a connection. Right now when I run this > code I get "Error: java.sql.SQLException: [Microsoft][ODBC Driver > Manager] Data source name not found and no default driver specified". > I'm not sure I have the odbc driver setup correctly either. I > downloaded "mm.mysql-2.0.11" but I'm not really sure how to bring it > into the mix as far as the driver goes. > > Thanks for any direction. > > Chris Stewart > [EMAIL PROTECTED] > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php