Eclipse can connect in database perspective, but Java program can't

I am totally new to JAVA, so I expect I am making a prize goof somewhere...
On my Macbook Pro (OS X 10.5) I have installed MySql and Eclipse and I have created a database with a number of tables populated with data (using phpmyadmin).
I seem to have the drivers in the right places and the classpath set correctly, because I can see my database, tables and columns in the "database perspective" in Eclipse. (I can see and manipulate my database in a variety of admin tools - so I think I have my user id, password and permissions set correctly.)
So, Eclipse can connect to my data base, but the following little Java test program can't can't connect to it.
I copied this sample test program from a website and supplied the parameters for user id, password and url, but I get the console message, "cannot connect to database server" each time i run it within the Eclipse sdk:
import java.sql.*;*
public class connect
public static void main (String[] args)
Connection conn = null;
try
String userName = "root";
String password = "mypassword";
String url = "jdbc:mysql://localhost:3306/testdatabase";
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 */ }
Any Ideas why eclipse can connect, but this little program can't?

Almost nothing uses the system classpath anymore. IDE's, when they execute and compile projects, setup "custom" environments for those projects, web containers and application servers do the same for the applications they are responsible for, applets use the "codebase" and "archive" params, when you use the "-cp" option, the System classpath is also ignored, and when you use "-jar" both "-cp" and the system classpath are ignored. IOW, never depend on the system classpath. That is an outdated way of managing your environments, especially when you have applications running on varying versions of the JVM.

Similar Messages

  • My safari can connect to the Internet, but other apps can't. I am using ipad3 wifi edition

    My safari can connect to the Internet, but other apps can't. I am using ipad3 wifi edition

    I have managed to resolve it. What I found is I typed in a wrong password when one app loaded. That app gave a misleading network connectivity error. Other apps are connecting fine now.

  • Can Connect via Database Control but Cannot Connect from Enterprise Manager

    Hi experts,
    This is a 10g database on a Windows server.
    when I remote into the server:
    - I CAN connect via the web-based Database Control
    - I CANNOT connect to any db/instance via regular Ent Mgr - get the ugly "ORA-12154 TNS: could not resolve the connect identifier specified" error.
    I thought both tools used the same connection files (tnsnames, listerner etc), but maybe not.
    When db control connects, but Enterprise Manager cannot, what should I check to find the problem?
    Thank you.
    John

    Thanks madrid.
    I eventually got it to work by changing the tnsnames.ora in the client_1 folder
    This is the original:
    FS9ENFP1 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = FS9ENFP1)
    (SERVER = DEDICATED)
    ORCL=
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = orcl)
    (SERVER = DEDICATED)
    EXTPROC_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    (CONNECT_DATA =
    (SID = PLSExtProc)
    (PRESENTATION = RO)
    I removed the EXTPROC entry and added entries for the ORCL and FS9ENFP1 databases, specifying server_database like this:
    FS9ENFP1_PNCLAFDB =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = PNCLAFDB)(PORT = 1521))
    (CONNECT_DATA =
    (SID = FS9ENFP1)
    (SERVER = DEDICATED)
    Not really sure WHY it is necessary to list an instance twice, once without server name and another with server name... but EM is able to connect now. I simply modeled tnsnames after another Oracle server where EM was able to connect.
    John

  • I just put Facetime on my MacBook and Ipad. I can connect and recieve video but no sound. The other person can hear me. If I use Skype everything works fine. I can't find any where in Facetime to change settings for the audio. Any suggestions

    I just put Facetime on my MacBook and Ipad. I can connect and recieve video but no sound. The other person can hear me. If I use Skype everything works fine. I can't find any where in Facetime to change settings for the audio. Any suggestions

    Options for when an iOS device gets locked because of forgotten passcode:
    Restore (and reset passcode) on your device by connecting it to the last computer to which it was connected:
    iTunes: Backing up, updating, and restoring iOS software - http://support.apple.com/kb/HT1414
    If you cannot connect it to the computer to which the device was last connected (or the device was never connected to a computer) you will have to use recovery mode to completely reset the device, losing all data:
    iOS: Unable to update or restore - http://support.apple.com/kb/HT1808 - recovery mode (e.g., cannot connect to computer last used to sync device, iTunes still asks for a password)
    If recovery does not work there's:
    DFU mode: http://osxdaily.com/2010/12/04/ipad-dfu-mode/
    How to put iPod touch / iPhone into DFU mode - http://geekindisguise.wordpress.com/2009/07/16/how-to-put-ipod-touch-iphone-into -dfu-mode/

  • I am trying to connect my mac and PC through my network. the pc can seen and connect with the mac, but my mac can only see the pc it can't connect. how do i fix this?

    i am trying to connect my mac and PC through my network. the pc can seen and connect with the mac, but my mac can only see the pc it can't connect. how do i fix this?

    FORCE IPAD INTO RECOVERY MODE
    1. Turn off iPad
    2. Turn on computer and launch iTune (make sure you have the latest version of iTune)
    3. Plug USB cable into computer's USB port
    4. Hold Home button down and plug the other end of cable into docking port. Do not release button until you see picture of iTune and plug.
    5. Release Home button.
    ON COMPUTER
    6. iTune has detected iPad in recovery mode. You must restore this iPad before it can be used with iTune.
    7. Select "Restore iPad"...
    Note: Data will be lost

  • EA3500 Phones can connect to wireless router, but cannot transfer data

    Ok, Since Cisco is completely helpless on helping me (this is why we are switching from Cisco stuff to other brands like Aruba at my work) I was thinking you guys would help me.  I got hanged up twice on this problem.  TWICE.
    So, my phone and my friends phones can connect to the wifi but I cannot receive nor send data from it.  The phones work completely fine elsewhere.  Here is the kicker, my computer works completely OK on the router and my phone used to work for 3-4 hours before this issue started going again.  Now it is constantly.  I restarted the modem, default reset it and still nothing.  I get an IP address too and it stays connected.  Any help.  Cisco thinks its the phone, but its multiple phones that are having the problem and my phone and other works completely fine at other places.

    The quickest way to get your phones working is to configure them staticly. More than likely........either your modem, your firewall, your router, or your ISP is blocking the proxy. Try using Google Public DNS. 8.8.8.8 and 8.8.4.4 Disable any proxy blocking features of your modem or firewall.
    Sometimes simply changing the DNS on your router to Google Public DNS might fix the problem.
    http://www.ehow.com/how_8275878_put-static-ip-iphone.html
    http://unlockforus.blogspot.com/2012/05/how-to-use-static-ip-address-at-android.html
    http://homekb.cisco.com/Cisco2/GetArticle.aspx?docid=816d2158e9e84c6da97fc236b4234ae2_3954.xml&pid=8

  • Can connect to wireless router but not to the internet

    Please Help, I have a WRT150N and I can connect to my wireless router by it will not connect to the internet from there, even though the internet, wireless, and security lights are lit up. If I plug a cord into the back of the router and then into my computer, I can connect to the internet, but once I disconnect the cable, I can still find and connect to my wireless router, but it will not connect to the internet from here. Under access it says "Local Only", I have the security type set to "Shared" under the security properties, and set to "WEP" with WEP key #1 entered. I have spent about 4 hours working on this problem now and could really use some help. Thanks.

    Type ipconfig /all in command prompt(cmd.exe) to see whether it displays valid and correct IP, netmask, gateway and DNS info. If not, take a look on these cannot connect to wireless network problem and using ping to troubleshoot network problem articles to get more ideas. Hope it helps..

  • A mac, a laptop and a pc can connect to the net, but pc can not conenct to mac or laptop

    It's tricky. I have a wireless wrt54g router working off of a comcast cable modem. I have the mac, the laptop and the pc all wired into it. The mac (os X) and the laptop (windows XP) can see and talk to each other and connect to the net. The pc downstairs (windows XP, same version as laptop) can connect to the net, but not to the mac or the lap top, yet it does show up in the network windows of both. I ran the windows network diagnostic and it told me that Default IP Gateway 192.161.1.1 passed, but IP Address 192.168.1.101 failed. I checked the router and the starting IP Address is 192.161.1.100 The same diagnostic on the laptop tells me that IP Address 192.168.1.108 passed. Can anyone tell me why IP Address 192.168.1.101 failed? As far as I can tell both the laptop and the pc have the same internet settings. Thanks Mark

    Yes, they need to run bonjour for windows.
    The Extreme should also use all short names, no spaces and pure alphanumeric.. it has to meet SMB standard.
    Hard disk should also conform to that.
    Open Windows Explorer and type directly into the address the name or the IP of the AE.
    \\AEName or \\AEIPaddress (replacing with actual name or IP).
    If that fails.. try ping.. open a command windows and ping the AE by name or IP.
    You can be pretty sure any failure is caused by name issues or firewall issues.. turn off all firewalls and force the computers to home location.

  • HT4356 I have a cannon mg3120 air printer and it is connected to my wifi but my iPad can not find a printer, what can I do

    I have a cannon mg3120 air printer and it is connected to my wifi but my iPad can not find a printer, what can I do

    1. Reboot iPad
    2. Reboot router

  • Hi, i can connect to the internet but mail will not download and i cannot open webpage ?? please help

    hi, i can connect to the internet but mail will not download and i cannot open a webpage?? any ideas

    Try #2 and #3 in link below. If neither work, you most likely have a hardware issue.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

  • Ive recently moved to Muscat in Oman and had wireless installed in my apartment.  I can connect to my laptop but my Ipad will not connect.  Any suggestions

    Trying to connect to my Ipad.  I've used it in coffee shops in Muscat and the hotel without any problem.  I've now had wireless installed in the apartment.  I can connect to my laptop but I cannot get the Ipad connected to the wireless - I've tried everything.  Any suggestions would be gratefully appreciated.  I've also tried Omantel who installed the wireless without any help.

    Usually I suggest checking that your WiFi router firmware is up to date, but your router was just installed.  Still, it might be worth checking with the manufacturer's web site.
    Here are Apple's support articles:
    iPad:  Troubleshooting WiFi networks and connections:  http://support.apple.com/kb/TS3237
    iPad:  Issues connecting to WiFi networks:  http://support.apple.com/kb/TS3304

  • What web player I use on my ipad2 bot watch live sports and how I get it?   PLEASE HELP. Also since I updated my ipad2 to ios6 cannot connect to iTunes  so cannot get no apps nothing can connect to App Store but can't get nothing it's brand new?

    What web player can I get on my ipad 2 so I can watch live sports? And how comes since I updated to ios6 I cannot acces the iTunes can connect to App Store but can't get nothing at all from there? PLEASE HeLP

    Just connect the new iPod to your computer and setup the iPod via iTunes (instead of via wifi).
    If you want to copy all the infor from an old iPod touch to the inew iPod see:
    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device

  • HT201320 My email account is set up properly, I can connect to the Internet, but I cannot get mail from the Mail app.

    My mail account is set up properly, I can connect to the Internet, but I cannot get mail from the Mail app on my iPad.

    Hello echo1946
    Start with the first article to troubleshoot the issue of not getting mail on your iPad. When you get online using safari, check to see if you can log into webmail. Also keep in mind, depending on the account that mail sometimes might not come in if it is a POP account as it may have already been download elsewhere.
    iOS: Troubleshooting Mail
    http://support.apple.com/kb/ts3899
    Mail Settings Lookup
    https://ssl.apple.com/support/mail-settings-lookup/
    iCloud: IMAP
    http://support.apple.com/kb/PH2585
    Regards,
    -Norm G.        

  • I have an 8GB ipod touch and suddenly I'm able to access only the "sent" mailbox of Mail and not the other mailboxes.  I turned on and off.  I connected it to MacBook but still I can't access the other mailboxes.

    i have an 8GB ipod touch and suddenly I'm able to access only the "sent" mailbox of Mail and not the other mailboxes.  I turned on and off.  I connected it to MacBook but still I can't access the other mailboxes.

    - Try resetting the iPod:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - Can you access the mail on another device?

  • My iphone 3g have earlier had connection to Wi-Fi,but now it can`t connect with Wi-Fi. Why?

    My Iphone 3g have earlier had connection to Wi-Fi, but now it can`t connect.Why? If you can help I`m very grateful because i have tried alot of things and can`t find out?

    We have try to reset the phone and a new programware. We tried to connect it with differrent Wi-Fi.The trouble is that when we write the password - we get the answer that the password is wrong. And this has worked before.And another wi-fi tells us that it can`t connect.

Maybe you are looking for