Can't Connect to the Mysql Database using J2SE jdk1.5

Can anyone tell me why this error occurs ????????????????????
Following are the codes ;
package dbconnect2;
import java.sql.*;
public class dbconn2 {
public static final String URL =
"jdbc:mysql://localhost:3306/test";
public static final String USERNAME = "test";
public static final String PASSWORD = "password";
* @param args the command line arguments
public static void main(String[] args) throws Exception {
// TODO code application logic here
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(URL,
USERNAME, PASSWORD);
Statement stm = connection.createStatement();
ResultSet rs = stm.executeQuery("select * from emp");
while (rs.next())
String strnaam = rs.getString("emp_name");
System.out.println(strnaam);
finally {
if (connection != null)
connection.close();
================================================================================
This is the run time error ;
init:
deps-jar:
compile:
run:
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at dbconnect2.dbconn2.main(dbconn2.java:39)
Java Result: 1
BUILD SUCCESSFUL (total time: 2 seconds)
please help me to sort this out
Thanks
Sishani

I've solved the DW problem by changing the site folders from
'db' to 'wwwroot' e.g. 'C:\CFusionMX\db\' is now
'C:\CFusionMX\wwwroot\
However I'm now back to my original problem. I've lost my
mqysql connection in CF Adminstrator. Before I made these changes I
could connect to my mysql databases using the following settings:
JDBC URL: jdbc:mysql://localhost:3306/test
Driver Name: MySQL Connector J
using the following Java path and file:
C:\CFusionMX\wwwroot\WEB-INF\lib\mysql-connector-java-3.0.17-ga-bin.jar
Now these settings give me the following error:
"Connection verification failed for data source: javaserver
[]java.sql.SQLException: SQLException occurred in JDBCPool
while attempting to connect, please check your username, password,
URL, and other connectivity info.
The root cause was that: java.sql.SQLException: SQLException
occurred in JDBCPool while attempting to connect, please check your
username, password, URL, and other connectivity info"
Any suggestions on this would also be welcome.
Thanks again to everyone for their help.
Sincerely,
Graham A. Kerby

Similar Messages

  • How to connect to the mysql database using applet from remote PC

    Hii All..
    I am also facing a problem.
    My web server and mysql server are running on the same PC.
    when i connect to the database from the same PC.
    Its connection but when i am trying to connect to the database from the different PC its giving error and not finding the driver "com.mysql.jdbc.Driver" because this is there on the server PC and applet runs on the client side..
    So to load the deriver on the client side so that it can run the applet to make the database connection on the remote PC.
    Thanks
    Uttam

    You are missing the library on the client.
    It must be moved to the client.
    Just like any other library that an applet requires.
    And that has nothing to do with JDBC.
    There are certainly way(s) to do it. Perhaps a forum that addresses applets, web usage or guis would provide an answer.

  • SharePoint Server 2010 can't connect to the Configuration Database

    Hi Techys,
    I have  a SharePoint Server 2010  Farm, and I have Installed SharePoint SP1 package,
    Then I,m trying to run the SharePoint configuration wizard, That time i have the below error.
    "Can't connect to the Configuration Database"
    I have checked all the services belongs to the sql server and SharePoint server.
    here i found, SharePoint Timer service is automatically Stopped while browsing the Central admin url.
    Please help me to resolve the above issue.
    Many Thanks,
    Madhu

    What you mean error in Config wizard, could you please share the complete error log?
    For Timer Services, check under which account it is running and check event log why its stoped?
    for CA error there are couple of possible reason for this:
    Make sure SQL related instances / services are running fine.
    Make sure your farm admin account have permission on config DB.
    Make sure Config Database Exist.
    Make sure you can connect to SQL server from your APP /WFE.
    If everything is running fine, then you may need to reconfigure the sharepiont products and technologies configuration wizard. The issues might be because of the update that might have installed some additional components for installation.
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • I've updated to yosemite from Mavericks, but since i can't connect to the internet I used my time machine back up which was march 2013. Now my macbook pro won't start and ends with a prohibited ted sign. Any suggestions pls.

    I've updated to yosemite from Mavericks, but since i can't connect to the internet I used my time machine back up which was march 2013. Now my macbook pro won't start and ends with a prohibted sign. Any suggestions pls.

    Install or Reinstall Yosemite, Mavericks, Mountain Lion, or Lion from Scratch
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    How to Clean Install OS X Yosemite
    OS X Mavericks- Erase and reinstall OS X
    OS X Mountain Lion- Erase and reinstall OS X
    OS X Lion- Erase and reinstall Mac OS X
    Note: You will need an active Internet connection. I suggest using Ethernet if possible
                because it is three times faster than wireless.

  • I can not connect to the internet while using my ipad I get a message saying Safari could not open the page because the server stopped responding need help thank you

    I CAN NOT CONNECT TO THE INTERNET WHILE USING MY IPAD I KEEP GETTING A MESSAGE SAYING SAFARI COULD NOT OPEN THE PAGE BECAUSE THE SERVER STOPPED RESPONDING PLEASE HELP THANK YOU

    Try the following:
    1. Turn router off for 30 seconds and on again
    2. Settings>General>Reset>Reset Network Settings
    3. Reset iPad; hold the Sleep and Home button down until you see the Apple Logo

  • I can not connect to the app store using my iphone 5

    I can not connect to the app store using my iphone 5.  When I first got it I was able to-but not since???
    Please help

    Come on guys.  Help me out.  When I click on the app store icon, it'll just go to a blank screen.  The only time there is anything on the screen is under the updates tab.  Then it just says no updates found.  I can not browse apps or search for them.  It just goes to blank screen

  • TS1398 I can't connect to the internet while using wi fi on my iphone 4S.

    I can't connect to the internet while using wi fi on my iphone 4S. I can connect on my computer and on my IPad but not with my iphone. I have tried everything. Once or twice it did connect but then disconnected immediately. I have tried everything.

    LeeinSunnyIsles wrote:
    I can't connect to the internet while using wi fi on my iphone 4S. I can connect on my computer and on my IPad but not with my iphone. I have tried everything. Once or twice it did connect but then disconnected immediately. I have tried everything.
    If you have truly tried "everything" then there is no hope of it ever working again. However, have you tried rebooting your router?
    Have you tried Settings/General/Reset - Reset network settings?

  • Connecting to a Mysql database using CF Administrator and DW

    I can't create a mysql datasource in CF Administrator.
    If I use the following datasource settings in CF
    Administrator:
    JDBC URL: jdbc:mysql://localhost:3306/test
    Drive Class: MySQL Connector J
    AND (note the emphasis) I set my local and remote folders in
    my DW site local folder, remote folder and testing server folders
    all to C:\CFusionMX\db\, I can connect to my mysql database in CF
    Administrator.
    However, with these DW site folder settings, DW doesn't
    recognize any databases (Access or Mysql) at all.
    When I change my DW site folder settings to 'wwwroot'
    (e.g.local folder C:\CFusionMX\db\' is changed to
    'C:\CFusionMX\wwwroot') DW now lists all my CF Administrator
    databases.
    The problem is CF Administrator can't connect to my Mysql
    data sources. It gives me the error:
    "Connection verification failed for data source: javaserver
    []java.sql.SQLException: SQLException occurred in JDBCPool
    while attempting to connect, please check your username, password,
    URL, and other connectivity info.
    The root cause was that: java.sql.SQLException: SQLException
    occurred in JDBCPool while attempting to connect, please check your
    username, password, URL, and other connectivity info"
    I've tried changing the 3306 port to 8500, but this doesn't
    help.
    My java path and connector file is:
    C:\CFusionMX\wwwroot\WEB-INF\lib\mysql-connector-java-3.0.17-ga-bin.jar,
    Is this a ID/password problem? I've tried both 'root' and
    leaving the ID field in the CF Administrator add data source block,
    both to no avail. I don't have a password set in Mysql for 'root'
    either.
    Any help would be gratefully appreciated. I've been working
    on this for weeks and keep running into one problem after another.
    Thanks a million in advance.
    Sincerely,
    Graham A. Kerby

    1) ensure mysql server is running
    2) there are numerous tutorials for mysql installation out
    there
    3) there are good free mysql admin tools out there
    4) use both the above to verify your mysql installation is
    correct
    5) please tell me you do have your zonealarm DISABLED
    hth
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Connecting to a Mysql database using a ColdFusion server

    can't create a mysql datasource in CF Administrator.
    If I use the following datasource settings in CF
    Administrator:
    JDBC URL: jdbc:mysql://localhost:3306/test
    Drive Class: MySQL Connector J
    AND (note the emphasis) I set my local and remote folders in
    my DW site local folder, remote folder and testing server folders
    all to C:\CFusionMX\db\, I can connect to my mysql database in CF
    Administrator.
    However, with these DW site folder settings, DW doesn't
    recognize any databases (Access or Mysql) at all.
    When I change my DW site folder settings to 'wwwroot'
    (e.g.local folder C:\CFusionMX\db\' is changed to
    'C:\CFusionMX\wwwroot') DW now lists all my CF Administrator
    databases.
    The problem is CF Administrator can't connect to my Mysql
    data sources. It gives me the error:
    "Connection verification failed for data source: javaserver
    []java.sql.SQLException: SQLException occurred in JDBCPool
    while attempting to connect, please check your username, password,
    URL, and other connectivity info.
    The root cause was that: java.sql.SQLException: SQLException
    occurred in JDBCPool while attempting to connect, please check your
    username, password, URL, and other connectivity info"
    I've tried changing the 3306 port to 8500, but this doesn't
    help.
    My java path and connector file is:
    C:\CFusionMX\wwwroot\WEB-INF\lib\mysql-connector-java-3.0.17-ga-bin.jar,
    Is this a ID/password problem? I've tried both 'root' and
    leaving the ID field in the CF Administrator add data source block,
    both to no avail. I don't have a password set in Mysql for 'root'
    either.
    Any help would be gratefully appreciated. I've been working
    on this for weeks and keep running into one problem after another.
    Thanks a million in advance.
    Sincerely,
    Graham A. Kerby

    If it were me I would use the MySQL JDBC driver and not ODBC. Then DSN versus not-DSN wouldn't be an issue.

  • Not able to connect to remote MySQL database using Connector/J

    I have an application that uses a connection pool for database access.
    It is initialized with this context.xml entry:
    The db server is running on port 3307.
         <Resource name="jdbc/DB" auth="Container"
                        type="javax.sql.DataSource" username="un" password="pw"
                        removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true"
                        driverClassName="com.mysql.jdbc.Driver"
                        url="jdbc:mysql://localhost:3307/myDB"
                        maxActive="8" maxIdle="4"/>Now after starting the context, I can see I have a connection to my database using the MySQL Administrator. So I know I am connecting.
    The problem is, when I try to query any table in the db, I get this message:
    java.sql.SQLException
    : Table myDB.TABLE_NAME' doesn't exist
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(
    MysqlIO.java:2921) ...
    I know it does in fact exist because I am looking at it. And the code I am using works perfectly fine as long as it is running on a local db server.
    Any ideas?

    I know it does in fact exist because I am looking at
    it. And the code I am using works perfectly fine as
    long as it is running on a local db server.
    Any ideas?Yes two.
    I am bit unclear about the last thing you said... you are testing with two different servers or two different clients?
    Anyway here are the possibilities off the top of my head.
    1) Some sort of security issue. Surrounding who and from where users can connect to the database in question.
    2) Case sensitivity problem. On Windows MYSQl makes all it's table names lower case only. Then it onlu supports the correct case to access them.
    For example
    CREATE TABLE TestMe
    Can then only be accessed with
    SELECT * FROM testme
    Not TestMe.
    This appears to vary with version but i have seen this issue before.

  • Can we connect and access SAP database using db adapter?

    Hi,
    I need couple of details:
    1) Can we connect to SAP database using db adapter and run select query to extract data from the SAP database tables?
    2) Where can I download SAP adapter? How to install it? and how to plug that in to the JDev?
    Cheers

    1) Can we connect to SAP database using db adapter and run select query to extract data from the SAP database tables? It is possible as long as back-end DB version of SAP are supported by DB adapter. Oracle recommends SAP connectivity through Oracle Application Adapter for SAP rather than direct connection to SAP Database tables.
    2) Where can I download SAP adapter? How to install it? and how to plug that in to the JDev?http://www.oracle.com/technology/products/integration/adapters/pdf/DS_OracleASAdapter_SAP.pdf
    http://www.oracle.com/technology/software/htdocs/devlic.html?url=/technology/software/products/ias/htdocs/101202.html
    http://download.oracle.com/docs/cd/E12524_01/doc.1013/e14201/toc.htm (Installation)
    http://download.oracle.com/docs/cd/E12524_01/doc.1013/e14196/toc.htm (SAP adapter configurtation)
    Manoj

  • CS4 can't connect to any MySQL databases

    The MySQL connections stopped working recently from Dreamweaver CS4, even though they still work for the assocated PHP pages when accessed from a web browser. I get this message: "Dreamweaver could not securely connect to your server. It's possible that your SSL certificates are not installed correctly." I should mention that I'm working from a new machine with a fresh installation of CS4, importing the sites from my old machine.

    Hi Carston
    I am upgrading from Dreamweaver 8 (where all 24 of my sites were working) to Dreamweaver CS5.  When I try to make the database connection file I get the error:
    The files from the _mmServerScripts folder are for the server PHP-MySQL.  You try to connect to a database using a different server model.
    Please remove this folder outside the Dremweaver environment on both local and testing machines and try again.
    OR
    HTTP Error Code 404 File Not Found.
    2)The testing server specified for this site does not map to the http://www.site name/sitename/_mmServerScripts/MMHTTPDB.php URL. Verify that the URL Prefix maps to the root of the site.
    I opened up my sites with another FTP program and deleted the hidden folder _mmServerScripts from my remote servers. Then deleted the same folder from my local machine.  Finally one of my sites at PHPWebhosting worked.  I ended up deleteing all the other sites from the Site Manager and duplicating the site that worked.  I edited the copy to a different site and was able to get them to work one by one.  I only have one site now at DreamHost.com that is not working.
    These same site definitions I have been using for up to 3 years on some of my sites (and they are working in Dremweaver 8).  My problem has to do with the _mmServerScripts and all their parts.  There must be .js files involved as well??  It seems there should be a simple fix for this problem.
    Note:  When I click the test button in the sites setup dialog boxes, Dreamweaver is able to connect.
    Cheers,
    Terry

  • Accesing the mysql database using jsp

    hi. I'm trbing to access the mysal data base using the following jsp code. but it gives me the exception: Exception is: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    please help.
    <%@ page language="java" import="java.sql.*" %>
    <%
         String JDBC_DRIVER = ("com.mysql.jdbc.Driver");
         String DATABASE_URI = ("jdbc:mysql://localhost/MCQTest?user=root&password=vishanka" );
         Connection con=null;
         ResultSet rst=null;
         Statement stmt=null;
         int noOfQuestions = 30;
         String [] question = new String [noOfQuestions];
         try
              Class.forName(JDBC_DRIVER).newInstance();
              con=DriverManager.getConnection(DATABASE_URI);
              stmt=con.createStatement();
              rst = stmt.executeQuery("select question from question");
              while(rst.next())
                   for(int i = 1; i<=noOfQuestions; i++)
                        question[i-1] = rst.getString(i);
                        out.print(question[i-1]);
              rst.close();
              stmt.close();
              con.close();
         catch(Exception ex)
              {out.println("Exception is: " + ex.toString());ex.printStackTrace();}
    %>
    <html>
    <head><title>StudentRegistration Front</title></head>
    <jsp:useBean id="user" class="beans.User" scope="session" />
    <body>
    <font color="blue">
    <h2 align="center">
    <p>Welcome <jsp:getProperty name="user" property="name" />:
    </h2>
    </font>
    <form action="marking.jsp" method="post">
    <h4 align="center">
    <input type="submit" value="submit">
    </h4>
    </form>
    </font>
    </body>
    </html>

    sorry guys. the code is given below clearly.
    <%@ page language="java" import="java.sql.*" %>
    <%
         String JDBC_DRIVER = ("com.mysql.jdbc.Driver");
         String DATABASE_URI = ("jdbc:mysql://localhost/MCQTest?user=root&password=vishanka" );
         Connection con=null;
         ResultSet rst=null;
         Statement stmt=null;
         int noOfQuestions = 30;
         String [] question = new String [noOfQuestions];
         try
              Class.forName(JDBC_DRIVER).newInstance();
              con=DriverManager.getConnection(DATABASE_URI);
              stmt=con.createStatement();
              rst = stmt.executeQuery("select question from question");
              while(rst.next())
                   for(int i = 1; i<=noOfQuestions; i++)
                        question[i-1] = rst.getString(i);
                        out.print(question[i-1]);
              rst.close();
              stmt.close();
              con.close();
         catch(Exception ex)
              {out.println("Exception is: " + ex.toString());ex.printStackTrace();}
    %>
    <html>
    <head><title>StudentRegistration Front</title></head>
    <jsp:useBean id="user" class="beans.User" scope="session" />
    <body>
      <font color="blue">
      <h2 align="center">
        <p>Welcome <jsp:getProperty name="user" property="name" />:
      </h2>
      </font>
      <form action="marking.jsp" method="post">
         <h4 align="center">
             <input type="submit" value="submit">
        </h4>
      </form>
      </font>
    </body>
    </html>

  • Getting error while trying to connect to the oracle database using SQL Deve

    Hi everybody,
    I installed sql developer and want to make a new connection, but it shows:Status: Failure- Test failed:IO Error:The Network Adapter could not establish the connection.
    Please anybody help me. Appreciate you, in help.
    Thank You,

    This is usually a problem with either your connection definition, or the basic network setup.
    Try following the trouble shooting steps here

  • Error connecting to MySQL database using JNDI

    Hi,
    I'm trying to do a simple connection to a MySQL database using the JNDI look-up
    method.
    Have tried this with the PointBase database that came with WebLogic and got it
    to work successfully.
    However got the attached error message when I tried it on MySQL database. I tried
    this with both the WebLogic's driver for MySQL and also the one I downloaded from
    MySQL (com.mysql.jdbc.Driver), and both failed with the same error message.
    Offhand, it doesn't look like the connection pool is failing. Tested it with WebLogic's
    "Test Pool" function and it was alright.
    Also MySQL database is working properly. Test this by doing simple connection
    and retrieval with simple JDBC connections and it works.
    Any ideas what else I can check with regards to this problem?
    Thanks!
    [att1.html]

    Hi Joe,
    Attached is the config.xml for the domain that I'm working with. There are 3 connection
    pools set-up.
    The problematic Connection Pools are "MySQLCP" and "My JDBC Connection Pool"
    Thanks for your help in this!
    Joe Weinstein <[email protected]> wrote:
    show us the pool definition, as it is in the config.xml file.
    thanks
    joe
    Everbright wrote:
    Hi,
    I'm trying to do a simple connection to a MySQL database using theJNDI look-up
    method.
    Have tried this with the PointBase database that came with WebLogicand got it
    to work successfully.
    However got the attached error message when I tried it on MySQL database.I tried
    this with both the WebLogic's driver for MySQL and also the one I downloadedfrom
    MySQL (com.mysql.jdbc.Driver), and both failed with the same errormessage.
    Offhand, it doesn't look like the connection pool is failing. Testedit with WebLogic's
    "Test Pool" function and it was alright.
    Also MySQL database is working properly. Test this by doing simpleconnection
    and retrieval with simple JDBC connections and it works.
    Any ideas what else I can check with regards to this problem?
    Thanks!
    Error 500--Internal Server Error
    java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogic:pool:MyJDBCConnection Pool, props = {enableTwoPhaseCommit=false, jdbcTxDataSource=true,
    connectionPoolID=MyJDBC Connection Pool, dataSourceName=MyJDBC Data
    Source}.
    Nested Exception: java.lang.RuntimeException: Failed to Generate WrapperClass
         at weblogic.utils.wrapper.WrapperFactory.createWrapper(WrapperFactory.java:141)
         at weblogic.jdbc.wrapper.JDBCWrapperFactory.getWrapper(JDBCWrapperFactory.java:73)
         at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:242)
         at weblogic.jdbc.pool.Driver.connect(Driver.java:158)
         at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:444)
         at weblogic.jdbc.jts.Driver.connect(Driver.java:138)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:298)
         at jsp_servlet.__index._jspService(__index.java:142)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
         at weblogic.jdbc.jts.Driver.wrapAndThrowSQLException(Driver.java:395)
         at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:448)
         at weblogic.jdbc.jts.Driver.connect(Driver.java:138)
         at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:298)
         at jsp_servlet.__index._jspService(__index.java:142)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    [config.xml]

Maybe you are looking for