Pls help - cant connect to my database while my class is part of a package

Can anyone please tell me why one can't connect to a database, while the class is part of a package?
package Application;
import java.sql.*;
public class GameDatabase
GameDatabase ()
connect ();
public void connect ()
try
String url = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=Profiles.mdb";
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Connection dbcon = DriverManager.getConnection (url);
catch (ClassNotFoundException a)
System.out.println ("ClassNotFoundEx");
catch (SQLException e)
System.out.println ("SQLEx");
public static void main (String [] args)
new GameDatabase ();
gives a SQLexception while the "package Appplication;" is present,
yet works perfectly when its commented.
Any suggestions how to bypass this?

Well, it just cannot find the file? Maybe you've to supply a path?
Further on, one more lesson:
System.out.println ("ClassNotFoundEx");
System.out.println ("SQLEx");Please don't ignore exceptions. They are not intented for phun. Rather use e.printStackTrace();

Similar Messages

  • Help with connection to mysql database, Getting error : No suitable Driver

    Below is my code :
    1) i have added the mysql driver (mm.mysql-2.0.14-bin.jar)in my classpath
    2) the code is getting compiling properly
    3) while running it using tomcat, it says "NO SUITABLE DRIVER"
    PLEASE HELP !!
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class logincheck extends HttpServlet {
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws IOException, ServletException
    Connection con = null;
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    PreparedStatement stmt = null;
    ResultSet rs = null;
    String userid = request.getParameter("userid");
    String password = request.getParameter("password");
    try {
    /** LOADING THE DRIVER FOR MYSQL DATABASE ***/
    Class.forName ("org.gjt.mm.mysql.Driver";
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    } //End of try-catch 1
    try{
         /*** CONNECTING TO THE DATABASE USING DATABASE NAME, USERNAME AND PASSWORD */
    con = DriverManager.getConnection("jdbc:mysql://localhost:8080/own");
    /****** this checks whether the entry for the user is in the database *****/
    stmt = con.prepareStatement("SELECT *FROM userinfo WHERE userid = ? AND passwd = ?");
    stmt.setString(1,userid);
    stmt.setString(2,password);
    rs = stmt.executeQuery();
    if(!rs.next())
    else
         /****************** IF THE USER AND PASSWORD ARE VALID *****************/
    //} // END OF RS.....
    // NEED HTML FOR INVALID USERID SHOWING MESSAGE ...
    con.close();
    }catch(SQLException esql){
    System.out.println(esql.getMessage());
    } // End of try-catch 2
    } // goGet
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    throws IOException, ServletException {
    doGet(request, response);
    } // goPost
    } // end logincheck function ...

    And i see another thing that confuses me. Your URL connection string is
    con = DriverManager.getConnection("jdbc:mysql://localhost:8080/own"); meaning that your database is in your machine and listens in port 8080 for incoming connections. But that is the default port that Tomcat listens! Maybe you should change this line to
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/own");where 3306 is MySQL's default port.
    Hope these help.

  • Not able to connect to the database while configuring the Hyperion Planning

    Hi all,
    I am trying to configure Hyperion Planning, i am getting error while connection to the database,
    and i am not able to connect to the sqlserver management studio using sql server authentication mode, while installing sql server i selected as windows authentication mode,
    here is my environment:
    OS: Windows Vista
    Database: MS SQL Server 2005, with Windows authentication mode
    Hyperion9.3.1: Planning, Essbase server, shared services.
    can anyone let me know what is the error? or do am i missing any step,
    appreciate your help.
    Thanks
    Afjal

    Hi,
    First of all Vista is not supported as O/S for Hyperion server products, so if you encounter any problems it may be due to that.
    It is possible to use windows authentication mode but some have problems with it and end up going down the sql server authentication route.
    It is possible to change SQL server to mixed mode.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Solaris 10, Tomcat 5 Cant connect to a database

    Hi:
    I installed Solaris 10 in a Sun Sunfire V100 Server and installed Tomcat 5.5.20 with JDK1.5, when my application needs to connect to my database server (MS Windows 2000 with MS SQL SERVER 2000 by Port 1433) using JDBC, the application do nothing, There's no information in Tomcat and System logs, I think it is related with Solaris Security (IPFilter) open/closed ports but I am not sure.
    I tested the connection to the database using a java class program and got the next error: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
    Thanks for the help.

    I know nothing about tomcat & DBs, but you could
    try telnetting out from Solaris on various ports to
    connect to other services on the MSWin box.
    Eg,
    $ telnet 192.168.1.244 80
    will attempt to hit port 80 on the MSWin machine.
    You'll know what services WIndows is running.
    This'll help you isolate the problem, if you can get
    through on some ports rather than others. If can't
    get out at all at all, check that your network services
    are ok with
    # svcs -x
    'snoop' is also worth trying out on the Solaris box.
    snoop 192.168.1.244
    will give you brief info on packets.
    snoop -V 192.168.1.244
    will give you more info
    snoop -v 192.168.1.244
    will give you shedloads
    Apologies if these steps were already known to you.

  • HELP cant connect my new nokia c6-00

    cant connect my new nokia C6-00 to my laptop (windows vista business).
    First of all is not connected by cable (ca-101).
    I managed to connect it by bluetooth but nothing works via nokia pc suite (7).
    I failed to download NOKIA OVI from mobile (message:  downloading failed. downloaded file invalid)) and after downloading it from web, cant be installed
    (: an error occured during installation of assembly. 'poloicy.9.0.microsoft.vc90.crt,version='9.0.30729.4148",publickeytoken="1fc8b3b0a1e18e3b",processorarchitecture="86",type="win32-policy".)
    i m wondering why i bought my device
    ANY HELP APPRECIATED
    COSTAS BREZAS

    correction to the above mentioned problems.
    my phone is connected to laptop by cable but not to pc suite.
    All other problems remain. I cant download ovi from mobile, i download ovi from web but cant be installed (see windows message above).
    Meanwhile I cleaned cookies with nokia pc suite cleaner, and the whole registry with Auslogics registry cleaner, but again nothing.
    PLEASE HELP

  • Cant connect to Oracle database using oracle db client

    Hi All,
    I recently created a virtual machine running windows server 2008 on my windows 7 host. Oracle database 11g is already installed on host OS(windows 7) and I have installed oracle 11g client on the guest OS(windows server 2008) and trying to connect to oracle database from remote server using oracle client but getting this error:
    ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATAI am trying to connect using oracle client as below:
    C:\Users\Administrator>SET ORACLE_SID = HR84DEV
    C:\Users\Administrator>SQLPLUS /NOLOG
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Feb 10 06:16:34 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    SQL> CONNECT SYSADM/[email protected]
    ERROR:
    ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
    I have created database with name - HR84DEV
    HOST ip address is - 192.168.56.1
    I googled this error and as most of resources/blogs talked about having correct entry on listner.ora and tnsnames.ora file, I did the changes on both of these files accordingly.
    PFB the cotent of both of these files:
    tnsnames.ora
    # tnsnames.ora Network Configuration File: C:\MyApps\Oracle\product\11.2.0\dbhome_\NETWORK\ADMIN\tnsnames.ora
    # Generated by Oracle configuration tools.
    LISTENER_ORCL =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.1)(PORT = 1521))
    ORACLR_CONNECTION_DATA =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    (CONNECT_DATA =
    (SID = CLRExtProc)
    (PRESENTATION = RO)
    HR84DEV =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = HR84DEV)
    ORCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl)
    listner.ora
    # listener.ora Network Configuration File: C:\MyApps\Oracle\product\11.2.0\dbhome_\network\admin\listener.ora
    # Generated by Oracle configuration tools.
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = CLRExtProc)
    (ORACLE_HOME = C:\MyApps\Oracle\product\11.2.0\dbhome_)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ONLY:C:\MyApps\Oracle\product\11.2.0\dbhome_\bin\oraclr11.dll")
    (SID_DESC =
    (SID_NAME = HR84DEV)
    (ORACLE_HOME = C:\MyApps\Oracle\product\11.2.0\dbhome_)
    (PROGRAM = extproc)
    (ENVS = "EXTPROC_DLLS=ONLY:C:\MyApps\Oracle\product\11.2.0\dbhome_\bin\oraclr11.dll")
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.1)(PORT = 1521))
    ADR_BASE_LISTENER = C:\MyApps\Oracle
    Please not that I dont have any problem in connect to database locally.

    Thanks Nicolas,
    Actually, there was a problem with my oracle client installation. I uninstalled it and then installed back again but still, even after following your instructions I get some error.
    Here what I did:
    Created tnsnames.ora file as below:
    HR84DEV =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = HR84DEV)
    Placed it under appropriate directory and then checked the connection with database using the command shown below:
    C:\Users\Administrator>tnsping HR84DEV
    TNS Ping Utility for 32-bit Windows: Version 11.2.0.1.0 - Production on 10-FEB-2
    012 08:42:03
    Copyright (c) 1997, 2010, Oracle. All rights reserved.
    Used parameter files:
    C:\MyApps\Administrator\product\11.2.0\client_1\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
    (HOST = 192.168.56.1)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = HR84DEV)))
    OK (20 msec)
    Then tried to connect to database as below:
    C:\Users\Administrator>SET ORACLE_SID=HR84DEV
    C:\Users\Administrator>SQLPLUS /NOLOG
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Feb 10 08:25:56 2012
    Copyright (c) 1982, 2010, Oracle. All rights reserved.
    SQL> CONNECT SYSADM/SYSADM@HR84DEV
    ERROR:
    ORA-28547: connection to server failed, probable Oracle Net admin error
    But still getting error.
    I Googled this error and tried to figure out what the problem is and came across the possible cause which is because I haven't specify that the service should run as a user who is in domain admin group.
    well, I am not really sure about this and dont know what user name and password I should enter in OracleserviceHR84DEV-properties-log on-this account.
    do I really need to set this?

  • XBOX ONE. I have the xbox one and the airport time capsule and cant connect to most xbox live games and zero parties. I have 0 experience in all this but somehow was able to change NAT to open but still wont connect. HELLLPPPP

    Okay folks, I need your help out there.
    So the nerdy side of me went and picked up the XBOX ONE on release day. Its awesome by the way, BUT..... I cant seem to connect to most xbox live games and absolutely ZERO parties. At first I just thought it was something to do with the xbox itself and would eventually fix itself, but i was wrong. After looking into it on microsoft, i found out that it had to do with my NAT settings on the airport itself. I guess apple and xbox are not compatiable for xbox live and it makes it difficult to have an open NAT setting and is a huge PAIN.
    I was able to pinpoint one that the airport time capsule was blocking the IPV6 something or another. Anyways, I unblocked that, and reset the modem and time capsule and jumped on the xbox and now have open NAT settings but still cant connect to multi-player.
    Upon further searching, i was told to uncheck the UPNP on my time capsule as well, but have no idea how to find that.
    I know it seems confusing, but thats the best i can describe it.
    tthanks all

    Be a long long time before I see an Xbox One.. but whoever told you to uncheck the upnp in the TC.. tell them their dreamin' .. upnp is not support by Apple in any computer or router, never has been.. Apple deliberately wrote their own version called NAT-PMP to do the same thing.. dynamically open ports at the request of an application or client computer.
    So there is nothing like that to uncheck.. and as a matter of interest.. there no box to check or uncheck for NAT-PMP either.. since apple do not believe in end user adjustment of settings.. they simply do not exist.
    You will have to manually forward all ports required by the Xbox via the TC. For multi-player games you probably need to open more ports than the standard to allow just xbox live. You will need to check the ports required and open them.
    OR
    Buy a standard vista UPNP compatible router.. and use that.. and simply put the TC in bridge in the network.
    I have not seen posts yet about xbox one.. but there are plenty about xbox and ps3 and the fact that Apple really doesn't give a hoot about games consoles.
    This is a good basic post for older xbox.
    https://discussions.apple.com/thread/5385065?tstart=0

  • Pls help: no connection message after recover

    My Zen locked and when I rebooted I lost my songs. I used the recovery tool. The Zen Media Explorer and Window Media Player doesn't detect zen.
    When I plug zen into usb port the computer detects zen by a zen icon appearing on the lower right hand corner(by the time). A zen creative portable device box pops?up asking what action I want. When I select an option such as organize media files using creative media explorer the zen media explorer box says device not connected.
    -I tried using recovery tool
    -I checked to see if I have service pack 2 and I do
    -I tried different usb ports

    Open device Manager while player is connected Start>Control Panel>System>Hardware. Look under the portable devices for the player. Right click On the player choose unistall. Then reboot computer (unplug player) after computer is back up reconnect the player using a usb port on the back of the computer.Stay away from the recovery tools all it does is download firmware & if the player is not seem by windows you cant do it anyway. Here's a guide to see what your doinghttp://www.epizenter.net/e07_plugins...opic.php?95267Message Edited by coachop94 on 09-03-2008 03:02 AM

  • Please help, cannot connect to Access database with a jar file

    Hi, i created a jar file from my java project, using eclipse.
    When i try open the jar through command prompt, the following error is given:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find
    file '(unknown)'.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at Methods.con(Methods.java:15)
    at LoginScreen.getCmboLogins(LoginScreen.java:80)
    at LoginScreen.getJContentPane(LoginScreen.java:65)
    at LoginScreen.initialize(LoginScreen.java:46)
    at LoginScreen.<init>(LoginScreen.java:31)
    at DataUse.main(DataUse.java:25)
    No Connection to dataBASE
    The program runs fine within eclipse and the database is bundled in the jar.

    rohangr wrote:
    The program runs fine within eclipse Because the database isn't in the jar.
    ...and the database is bundled in the jar.That isn't going to work.
    The MS ODBC driver (which has absolutely nothing to do with java) expects to find the MS Access file in the windows file system.
    And the contents of the jar file does not fit into that requirement.

  • Pls. help:cannot connect to the internet. . . .sony ericsson cedar j108i

    PLEASE HELP
    how can i connect to the internet using my sony ericsson cedar j108i????

    http://www.sonyericsson.com/cws/support/phones/detailed/howtogetinternetsettings/cedar?cc=gb&lc=en Follow this link to download the settings directly to your phone.If this doesn't work, contact your network to get the settings sent to your phone by SMS.

  • HELP! connect to nokia suite while display broken

    I accidentally broke the display of my "Nokia E63 and now i cannot select nokia suite when connecting the usb cable to make a backup of my contacts because my phone is configured to use mass storage as default connection. either way even if i was being asked to select the connecton type it is still impossible because i have no screen.
    Please help me to can i get my contacts

    Hi Petkkko,
    Thank you for posting and welcome to the Nokia Support Discussions!
    Sorry for what happened to your phone. Can you tell us which saving memory do you use, SIM memory or Phone memory? Do you remember if you have changed the default saving memory to SIM? As far as I know, the default saving memory is phone. However, you may try to insert your SIM card to another device for us to check if your contacts were saved on your SIM. 
    Let us know what would be the outcome.

  • Help cant connect on In my room

    My dad recently got a E4200 router, My whole family are mac users, the connection are all okay with their computers, I'm the only one using Microsoft, ASUS running on Vista. The connection is fine when I'm near the router, but when I go to my room I get no connection at all, it connects for a second but then it goes on connection with limited acess, I don't know whats wrong can anyone help me? 

    I dont have any network

  • Help, Cannot connect to ODBC database using SQL Toolkit!

    Hello All,
    I am toying around with the SQL Toolkit evaluation (2.2 + the patch) and I am having difficulty.
    I ran the example program "connect" and it seems to work fine.
    However, I try to write my own program and I keep getting the same message:
    "Function DBConnect: (return value == -10 [0xFFFFFFF6]).
    Native error code - 2147467259 0x80004005
    The message differs from time to time, but the return value is constant.
    I am using both Microsoft SQL Server 2012 and MySQL.
    For MySQL I have installed the latest ODBC connector, 5.3.4. Inside the Control Panel/Data Sources(ODBC), I have a DSN named test_mysql in both User DSN and System DSN.
    I ran a test on the connection and the test passes. I am not sure if I should use the ansi or unicode driver, I have tried both with the same success.
    I am not sure I had configured the SQL Server connection properly, and will attempt that again.
    My CVI Code is simple enough:
    hdbc = DBConnect ("DSN=test_mysql"); 
    Every time I get a -10 from DBConnect. Either I have something configured wrong or I am missing something.
    Does anyone have any suggestions?
    Veni Vidi Duci
    Solved!
    Go to Solution.

    Update 2:
    After getting off the phone with Tech Support the problem has been identified!
    LabWindows SQL toolkit requires 32 bit DNS. My PC is a 64 bit, so my DNS manager defaulted to 64 bit.
    I needed to use the 32 bit DNS manager when working with the toolkit.
    Once I created my DNS connections using the 32-bit version of the ODBC Datga Source manager, everything worked fine.
    See this tech note:
    http://digital.ni.com/public.nsf/allkb/E7984C0DA0F0E65086257694005B4CB7
    Veni Vidi Duci

  • Pls help me error in creating DATABASE in ORACLE 8I

    I used Redhat 6.1 and installed Oracle 8.1.5.2 I think the oracle software is installed successfully. However, when I attempted to create the database by Database Configuration Assistant, I got an error message when I click on 'start' button.
    privileges and ORA-01012: not logged.
    How can I solve the problem to create my first database?,i m using the oracle account only and i have given all permissons to him
    Thanks a lot.
    Regards,
    chandru

    More info on my homepage, including "not logged in" and creating DB without using dbassist:
    http://homepages.tig.com.au/~jmsalvo/linux/oracle8i.html

  • Autoconfig cant connect to database.

    i was trying to change the domain name of oracle application 11.5.10.2 , by making changes in both .xml files . but when i was nt success , i return to what i had changes as i had the backup of old .xml files. but now when i m running adautocfg.sh in both the tirs, it cant connect to the database .
    ANY HELP ????

    Oracle Apps:11.5.10.2 OS: Redhat ES linux 3.0
    Yes i have changed the domain name back on the OS.
    The Autoconfig logfile when i run at dbtier says:
    Starting AutoConfig at Fri Dec 8 11:53:36 2007
    Using adconfig.pl version 115.64
    Classpath : /dev1/visdb/9.2.0/jre/1.4.2/lib/rt.jar:/dev1/visdb/9.2.0/jdbc/lib/ojdbc14.jar:/dev1/visdb/9.2.0/appsutil/java/xmlparserv2.zip:/dev1/visdb/9.2.0/appsutil/java:/dev1/visdb/9.2.0/jlib/netcfg.jar
    ===========================================================================
    Starting Utility to Report Version Conflicts at Fri Dec 07 11:53:36 IST 2007
    Using VersionConflictListGenerator.java version 115.2
    All driver files processed.
    No version conflict encountered.
    ===========================================================================
    Using Context file : /dev1/visdb/9.2.0/appsutil/VIS_wbsebdev1.xml
    Attempting to create a back up of the Context file
    Created back up file of name :
    /dev1/visdb/9.2.0/appsutil/out/VIS_wbsebdev1/12071153/VIS_wbsebdev1.xml
    ===========================================================================
    Starting synchronization of file system Context file and its templates with those in the database
    Database connection : Failed
    OAM Context editing support feature: Unverified
    OAM Customization support feature : Unverified
    File system template : /dev1/visdb/9.2.0/appsutil/template/adxdbctx.tmp
    Checking for customizations to Context template
    Warning: Unable to connect to Database.
    If the system is OAM enabled, this may result in loss of customizations.
    Looking for custom template at : /dev1/visdb/9.2.0/appsutil/template/custom/adxdbctx.tmp
    Custom template : Not available
    Customizations found : None
    This i m giving a part of logfile, where you can see "Database connection : Failed" in bold letter.

Maybe you are looking for

  • Issue in calculating sum on a column at the end of the report in Pivot view

    Hi, I have some columns like Hierarchy column A, Non Hierarchical columns B, C and a measure D. In Pivot view under rows I have placed columns A,B and C in Columns and D in measures. If I try to calculate sum of values at the end of report by using o

  • Error on installing 10.2.0.1 on RHEL ppc64

    I'm trying to install 10.2.0.1 on RHEL (uname -a: Linux TEMP 2.6.9-89.EL #1 SMP Mon Apr 20 10:25:13 EDT 2009 ppc64 ppc64 ppc64 GNU/Linux). The server under that linux is IBM p5 with power processor. Therefor installation pack is 10.2.0.1 for linux on

  • Konqueror error after upgrade

    I upgraded my system today, and when I try to browse website with konqueror it gives me only this message back: konqueror: ERROR: : couldn't create slave : Unable to create io-slave: klauncher said: Error loading 'kio_http'. Any suggestions?

  • Can't Set Up personal bbm or recieve pictures!

    I've had my phone since october and I Can't receive picture messages OR set up personal bbm. When I go to setup wizard-email setup it says select an email setup option: I want to use a work user with blackberry eneterprise user! That's ALL it says. I

  • Mouse lags after changing Harddrive

    After i installed my SSD in my Mac Mini and restored the Operation System (Mountain Lion) from my Time Machine Backup i encounter a very strange mouse lag. When i move the mouse, the cursor jumps almost every 3 seconds. I've tried already a different