Re: Why can't I make a connection?
Hi, I tried doing what Rhino suggested by coping the jar file I downloaded to the jre\lib\ext folder where my jdk is installed. The only thing that was different on my system than what Rhino described is that my hard drive only had a path jre\lib, but with no ext folder inside the lib directory. Inside that lib folder were folders named: audio, smm, fonts, images and security. I added an ext folder and then deposited my folder containing the jar file here: C:\Program Files\JBuilder6\jdk1.3.1\jre\lib\ext\mysql-connector-java-3.1.1-alpha\mysql-connector-java-3.1.1-alpha-bin.jar Does that look right? When I do that and register the driver with the DriverManager, I am not getting the original no driver available exception, instead the app throws an exception as follows. Am I moving in the right direction??: java.lang.NoClassDefFoundError: java/sql/Savepoint at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:218) at java.sql.DriverManager.getConnection(DriverManager.java:517) at java.sql.DriverManager.getConnection(DriverManager.java:199) at database_test.DBConnector.getConnection(DBConnector.java:54) at database_test.DBConnector.main(DBConnector.java:80) Exception in thread main The new source code is below for your convenience: public class DBConnector { //Class State private String dbuser,dbpasswd,dburl; public DBConnector() { dbuser=sspiegler; dbpasswd=cuatro; dburl= jdbc:mysql://localhost/menagerie?user=+dbuser+password=+dbpasswd; try { //Register the driver with the DriverManager Class.forName(com.mysql.jdbc.Driver).newInstance(); } catch(Exception e) { } } public DBConnector(String aDburl,String aDbuser,String aDbpasswd) { this.dbuser=aDbuser; this.dbpasswd=aDbpasswd; this.dburl=aDburl; } public Connection getConnection () throws SQLException { ResultSet rs=null; Connection conn=null; try { conn = DriverManager.getConnection(dburl); //Statement state = conn.createStatement(); //rs = state.executeQuery(SELECT * FROM pets); if (rs != null) { // here you would do something with the ResultSet } } finally { if (rs != null) { //rs.close(); } } return conn; } /** * *** for testing purposes only *** */ public static void main(String[] args) { Connection aConn = null; DBConnector dbc = new DBConnector(); try { aConn = dbc.getConnection(); } catch(SQLException sqle) { System.out.println(SQLException: + sqle.getMessage()); System.out.println(SQLState: + sqle.getSQLState()); System.out.println(VendorError: + sqle.getErrorCode()); } } } --- Mark Matthews [EMAIL PROTECTED] wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rhino wrote: Scott, I'm going to put this reply into the list rather than answer it offline. I hope that's okay with you. If I answer you offline, only you will know the answer but if I answer on the mailing list, everyone who monitors the list - and anyone who checks the archives in the future! - can benefit. The rest of my reply is interspersed in your note Rhino - Original Message - From: Scott D. Spiegler [EMAIL PROTECTED] To: Rhino [EMAIL PROTECTED] Sent: Wednesday, June 16, 2004 6:14 PM Subject: Re: Why can't I make a connection? 1. Have you installed a MySQL Java driver and is it accessible to the program? That's what I am not sure about. I placed the drivers in the location specified by the documentation or at least I think I have. Where do you usually place them? I followed this course of action from the docs: copy the com and org subdirectories and all of their contents to anywhere you like, and put the directory holding the com and org subdirectories in your classpath. I also added D:\mysql-connector-java\mysql-connector-java-3.1.1-alpha\mysql-connector-ja va-3.1.1-alpha-bin.jar; to my CLASSPATH variable under Start-System-Advanced-Environment Variables. Is that correct? I'm assuming you assigned that path to the CLASSPATH environment variable. If not, you should have ;-) I'm also assuming that the driver you are using is appropriate for the version of MySQL you are using. Since the classpath approach doesn't work for you, I'm going to suggest another approach, rather than trying to work out why your classpath isn't working. I have lately started putting my database drivers in the extensions library of the JRE and it's working very well. You
Why can't I make a connection?
Hi, I am testing the following code that attempts to get a DB connection, but I keep getting the following error: database_test.DBConnector SQLException: No suitable driver SQLState: 08001 VendorError: 0 The code snippet is below. I know the DB I am trying to connect to exists and that the userid and password is correct. I am not sure if I am giving the connect string the correct location of my menagerie DB or not. How can I figure out where it lives? public class DBConnector { //Class State private String dbuser,dbpasswd,dburl; public DBConnector() { dbuser=sspiegler; dbpasswd=cuatro; dburl= jdbc:mysql://localhost:3306/menagerie?user=+dbuser+password=+dbpasswd; } public DBConnector(String aDburl,String aDbuser,String aDbpasswd) { this.dbuser=aDbuser; this.dbpasswd=aDbpasswd; this.dburl=aDburl; } public Connection getConnection () throws SQLException { ResultSet rs=null; Connection conn=null; try { conn = DriverManager.getConnection(dburl); if (rs != null) { // here you would do something with the ResultSet } } finally { if (rs != null) { } } return conn; } /** * *** for testing purposes only *** */ public static void main(String[] args) { Connection aConn = null; DBConnector dbc = new DBConnector(); try { aConn = dbc.getConnection(); } catch(SQLException sqle) { System.out.println(SQLException: + sqle.getMessage()); System.out.println(SQLState: + sqle.getSQLState()); System.out.println(VendorError: + sqle.getErrorCode()); } } } = We don't see things as they are, we see things as we are. --Anais Nin __ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Not Getting DB Connection
Hi, I am using the following code but not getting a connection. :( Can someone tell me what I am doing incorrectly? Thanks, Scott package database_test; import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.DriverManager; import java.sql.SQLException; // Notice, do not import com.mysql.jdbc.* // or you will have problems! /** * pTitle: Phone # regex: ^([(]?\d{3}[-)]\d{3}-\d{4})*$ /p * pDescription: /p * pCopyright: Copyright (c) 2004/p * pCompany: /p * @author unascribed * @version 1.0 */ public class DBConnector { //Class State private String dbuser,dbpasswd,dburl; public DBConnector() { dbuser=sspiegler; dbpasswd=cuatro; dburl= jdbc:mysql://localhost:3306/menagerie?user=+dbuser+password=+dbpasswd; } public DBConnector(String aDburl,String aDbuser,String aDbpasswd) { this.dbuser=aDbuser; this.dbpasswd=aDbpasswd; this.dburl=aDburl; } public Connection getConnection () throws SQLException { ResultSet rs=null; Connection conn=null; try { conn = DriverManager.getConnection(dburl); Statement state = conn.createStatement(); rs = state.executeQuery(SELECT * FROM pets); if (rs != null) { // here you would do something with the ResultSet } } finally { if (rs != null) { rs.close(); } } return conn; } /** * *** for testing purposes only *** */ public static void main(String[] args) { Connection conn = null; DBConnector dbc = new DBConnector(); try { conn = dbc.getConnection(); } catch(SQLException sqle) { System.out.println(SQLException: + sqle.getMessage()); System.out.println(SQLState: + sqle.getSQLState()); System.out.println(VendorError: + sqle.getErrorCode()); } } } = We don't see things as they are, we see things as we are. --Anais Nin __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Unable to Programatically Create DB Connection
I am trying to programatically connect to my DB, but I am not sure what the connection string should be. I am using this statement: conn = DriverManager.getConnection(jdbc:mysql://localhost/test?user=scottpassword=cuatro); I am getting this exception message: database_test.DBConnector SQLException: No suitable driver SQLState: 08001 VendorError: 0 Any idea as to what the correct, connection string might be? Thanks, Scott = We don't see things as they are, we see things as we are. --Anais Nin __ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Unable to Create DB Connection
Hi Dave, --- Christensen, Dave [EMAIL PROTECTED] wrote: Did you set up a my.ini file in your Windows directory? If so, what is in the file? I found the problem about why I was not able to get my WinMySQLadmin tool to start the service. My my.ini contents are below this email the password x'd out. For some reason, I had told WinMySQLadmin to write the file to D:/MySQL/share/english instead of C:/MySQL/share/english. I've also verified that my.ini is living in C:\WINNT. The green light on WinMySQLadmin is now lit instead of the red light! :) With the green light lit, can I assume that the mysqld-nt is now running as a service or do I have to start myself? Now, when I type in the DOS shell: C:\mysql\binmysqld --console I get this. Is this correct? Cannot initialize InnoDB as 'innodb_data_file_path' is not set. If you do not want to use transactional InnoDB tables, add a line skip-innodb to the [mysqld] section of init parameters in your my.cnf or my.ini. If you want to use InnoDB tables, add for example, innodb_data_file_path = ibdata1:30M:autoextend But to get good performance you should adjust for your hardware the InnoDB startup options listed in section 2 at http://www.innodb.com/ibman.html mysqld: ready for connections Then, I tried to do this DB creation and post-installation testing, but mysql_install_db and mysqld_safe are not in my scripts directory: For a binary distribution (not RPM or pkg packages), do this: shell cd mysql_installation_directory shell ./scripts/mysql_install_db shell ./bin/mysqld_safe --user=mysql Here is the content of my my.ini file. Where to go from here?, Thanks, Scott : #This File was made using the WinMySQLAdmin 1.4 Tool #6/24/2003 5:42:24 PM #Uncomment or Add only the keys that you know how works. #Read the MySQL Manual for instructions [mysqld] basedir=C:/mysql bind-address=169.254.81.137 datadir=C:/mysql/data language=C:/MySQL/share/english #slow query log#= #tmpdir#= port=3306 #set-variable=key_buffer=16M [WinMySQLadmin] Server=C:/mysql/bin/mysqld-nt.exe user=scott password=xx = Scott D. Spiegler President Innovative Technical Solutions Pawtucket, RI 02861 __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Unable to Create DB Connection
Hi, I am using the binary distribution of mySQL for Windows-2000 and am not able to connect to the DBserver. I used the Setup executable to install the application. I verified that the my.ini file was created and contained appropriate information. But, when I right-click with my mouse on the stop light icon- to start the service- nothing happens. I tried to ping the port that mySQL was supposed to be listening at, and it said that the connection was refused. So, it seems like I have not done something properly. Any thoughts as to how to trouble shoot this problem? Thanks, Scott = Scott D. Spiegler President Innovative Technical Solutions Pawtucket, RI 02861 __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: Unable to Create DB Connection
Oh, right- I forgot to mention that. Part of the error message in trying to connect to the database said that it couldn't find the mysql.err file. I installed mySQL in C:\mysql but the error message from the DOS shell said it couldn't find the file: D:\mysql\data\english\mysql.err. I am not sure why it was looking for that file on the D drive when I expected it to look on C:\mysql\data\english\mysql.err. That may not be the precise path that I am quoting, but - let's assume it is for a minute- the message was confusing in that mySQL was looking for that file on my D drive, when the application is installed on C. Is there some way to tell mySQL to look in the a path of the C drive? Thanks, Scott --- Christensen, Dave [EMAIL PROTECTED] wrote: Scott, You should be able to find a file titled 'mysql.err' in your data directory. This file will contain information that should help you get started. -Original Message- From: Scott D. Spiegler [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 09, 2003 6:59 AM To: [EMAIL PROTECTED] Subject: Unable to Create DB Connection Hi, I am using the binary distribution of mySQL for Windows-2000 and am not able to connect to the DBserver. I used the Setup executable to install the application. I verified that the my.ini file was created and contained appropriate information. But, when I right-click with my mouse on the stop light icon- to start the service- nothing happens. I tried to ping the port that mySQL was supposed to be listening at, and it said that the connection was refused. So, it seems like I have not done something properly. Any thoughts as to how to trouble shoot this problem? Thanks, Scott = Scott D. Spiegler President Innovative Technical Solutions Pawtucket, RI 02861 __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] = Scott D. Spiegler President Innovative Technical Solutions Pawtucket, RI 02861 __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Unable to Create DB Connection
Hi, I am using the binary distribution of mySQL for Windows-2000 and am not able to connect to the DBserver. I used the Setup executable to install the application. I verified that the my.ini file was created and contained appropriate information. But, when I right-click with my mouse on the stop light icon- to start the service- nothing happens. I tried to ping the port that mySQL was supposed to be listening at, and it said that the connection was refused. So, it seems like I have not done something properly. Any thoughts as to how to trouble shoot this problem? Thanks, Scott = Scott D. Spiegler President Innovative Technical Solutions Pawtucket, RI 02861 __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]