How to set Classpath for MySQL

Hi
I want to connect to my mySQL db with a java program , but I don't know how to install the mySQL connector driver. Can anyone help me? or indicate somewhere where I might find the answer?
And how to set Classpath for MySQL.
my program gives an exception ClassNotFound.
Exception :com.mysql.jdbc.Driver
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 Files.main(Files.java:352)
Plz help me
Thanx
Lalit

to make your life easy i tried to connect..
what you have to do is.. you mysql database server should be running
next you have to download one of the version of mysql driver.. i downloaded mysql-connector-java-5.0.5
go to my computer right click - >advance tab -> click on environment variable -> put you path e.g. C:\Program Files\Java\jarFiles\mysql-connector-java-5.0.5\mysql-connector-java-5.0.5-bin.jar
into your classpath in a user variable section..
Try this code
import java.sql.*;
public class MySqlConnect{
     public static void main(String [] args){
          try{
               Class.forName("com.mysql.jdbc.Driver");
               String url ="jdbc:mysql://localhost:3306/test";
               Connection con =DriverManager.getConnection(url,"root", "password");
               System.out.println("Connection: " + con);
          }catch(ClassNotFoundException cnfe){
               cnfe.printStackTrace();
          }catch(SQLException se){
               se.printStackTrace();
}have fun
Gurnah

Similar Messages

  • How to set classpath for J2ME

    how to set class path for j2me. I downloaded J2ME Wireless tool kit. And set the classpath "set classpath=c:\J2mewtk\lib\midpapi.zip;.;". but i could compile java file. .how to set.
    With regards
    Santhosh

    When you are downloading j2MEWTK, everything is included within it. You dont require MIDP seperately. When you are runnung the ktoolbar , which is provided with J2mewtk, the preverifier runs and creates the required jad file for you. You dont need a forte to run these.
    If you want to download MIDP seperately, that also is possible. Then you have to go for command line arguments. Please refer to Sun's MIDP page for details.
    Let me know, if you face any further problem

  • How to set classpath for classes in war files

    Hi All,
    After deploying the WAR file I could access the JSP files but gives classnotfound exception when the information is expected from the java servlet.DO I need to set the classpath if yes how to do for the war file.
    thanks

    The web.xml,file structure and error is below let me know if more information is required.
    As you said weblogic is looking for the classes in lib directory inspite of having the classes in web-inf/classes directory.
    web-app>
    <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>com.test.site.pds.Controller</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/controller</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    </web-app>
    File Structure:
    C:\test\PDSWebApp\WEB-INF\classes\com\test\site\pds\*.class
    PDSWebApp
         css
         html
         images
         javascript
         jsp
         WEB-INF
         classes
         com/test/site/pds/*.java
         lib
         servlets
    The error:
    javax.servlet.ServletException: [HTTP:101249][ServletContext(id=18129862,name=PdsApp,context-path=/PdsApp)]: Servlet class com.test.site.pds.Controller for servlet ControllerServlet could not be loaded because the requested class was not found in the classpath C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\PdsApp.war;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\classes12.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-beanutils.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-collections-2.1.1.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-lang-2.0.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\displaytag-1.0.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\jstl.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\standard.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\_wl_cls_gen.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp.
    java.lang.ClassNotFoundException: com.test.site.pds.Controller.

  • How to set classpath for third party jdbc-driver

    my application contains bc4j jsp. when i try to run this jsp application which connect to postgresql, i get a error message
    "Application Error
    Return
    Error Message: JBO-30003: The application pool (App_ModLocal) failed to checkout an application module due to the following
    exception:
    Error Message: JBO-26061: Error while opening JDBC connection."
    how to solve this.

    The JDBC for your database should be added to your client project.
    In JDeveloper created a new 'named' library item and specify the JDBC jar files for your database.
    See also related article
    http://otn.oracle.com/products/jdev/howtos/bc4j/bc_pdb2walkthrough.html#edit
    - Sathish

  • Set classpath for java in fedora core 1?

    i am new to programming java on linux and im having trouble finding out how to set classpath in the shell, permenently. i have the sdk installed and tried the usual "hello world" test and failed. the response i would get a message telling me javac is not a bash command. i have no clue how to set classpaths in linux so i would much appreciate it if someone would show me thanks

    Ok, there is two ways to achieve this. Either by setting it globally for all the user, or only for your self. If you are working on your own station and have super user access, you can set it up for all th eusers, if not, just set it for your self. How ??
    for all the users, modify the file /etc/profile and include this:
    PATH=$PATH:/path/to/jdk/bin:.
    CLASSPATH=$CLASSPATH:/path/to/jdk/lib/tools.jar:/path/to/jdk/lib/rt.jar
    export PATH CLASSPATH
    If you want to add it only for ur self then, modify the lsame line in ~/.bash_profile
    hope this helps

  • How to set View for Completed items inside Tasks?

    How to set button for 'View' and see Completed items or not completed inside Tasks?

    Hi,
    You want to set custom views for Tasks folder so that when we click a view button, it will show all Completed or incomplete tasks, am I correct?
    Which version of Outlook are you using? There are existing views for completed/incomplete tasks in Outlook. In Outlook 2010 and Outlook 2013, we can find the buttons under View tab > Change View. Click Completed button to view all completed
    tasks; Click Active button to view incomplete tasks.
    In Outlook 2007, just click View > Current View to switch between different views.
    If I've misunderstood something, please feel free to let me know.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to set  password for BPEL domain

    Hi,
    I am new to SOA.
    I want to setup client-server environment for few developers.
    I installed SOA 10.1.3.3 in the server machine.
    And I created few domains in BPEL, one for each developer.
    It didn't ask me to set the password while creation of the domain.
    Please let me know how to set password for newly created domain so that each developer login to his/her own domain and manage processes.
    Thanks!!!

    Thanks for the prompt response.
    What roles should I give to my developers to allow them to manage their services in ESB control, BPEL control, WSM control.
    And I would like to know how to set the password for a BPEL domain too.
    Message was edited by:
    user644377

  • How to set password for every application

    Hi,
    As a administrator how to set password for every weblication in sharepoint 2013.
    Is there any way to set?
    Thanks,

    Who's password are you trying to set? Please provide more details.

  • How to set password for a zip file and should be checked when reading that

    Hi friends,
    how to set password for a zip file and should be checked when reading that file???
    thanks.
    Praveen Reddy.J

    Heyy man, i think, u did not get my problem.
    all i have to do is:
    i have to create a zip file, and we should secure it with password when creating. and whenever the user wants to open that zip file he should provide correct passowrd otherwise he could not read that file. So, we should check for that also.
    Tanks for reply.

  • How to set password for Local are connection?

    How to set password for Local are connection?

    do you mean the 802.1x authentication?
    check out links below:
    http://www.cisco.com/c/en/us/td/docs/switches/lan/catalyst2950/software/release/12-1_9_ea1/configuration/guide/scg/Sw8021x.html
    http://technet.microsoft.com/en-us/network/bb545365.aspx
    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    IT Stuff Quick Bytes

  • How to set value for trim and bleed using jsx script?

    I have tried using bleedoffsetRect but somehow it is not working. Can anybody please help me on how to set value for trim and bleed using jsx script? Any example will be highly appreciated.
    Following is the code I am trying with:
    var _saveName = new File ( root_path +_strFileName+".pdf");
        var _saveOpts = new PDFSaveOptions();
        _saveOpts.printerResolution = 300; 
        var bleedarray = new Array();
         bleedarray[0] =9.00;
         bleedarray[1]=9.00;
         bleedarray[2]=9.00;
         bleedarray[3]=9.00;    
        _saveOpts.bleedOffsetRect = bleedarray;

    I would expect although I've not actually tried this for the bleed off set box to be larger than the artbaord and the first two values to be negative or 0…
    var bleedarray = new Array(-9,-9,artboard.width+9,artboard.height+9);
    Where 'artboard.width' & 'artboard.height' you will have calculated from your file. An Array(9,9,9,9); would not constitute any boxes bounds.

  • How to set sourceURL for MS Access database in other computer?

    How to set sourceURL for MS Access database in other computer?
    getConnection("jdbc:odbc://www.micrsoft.com:9999/msaccess");
    How do you determine the port for the MS Access?
    Thank you very much.

    How to set sourceURL for MS Access database in other computer?You don't.
    How do you determine the port for the MS Access?You don't.
    Databases like Oracle and MS SQL Server have 'server' software which runs on a server computer. Requests talk to that server software. MS Access does not have a server, so there is nothing to talk to.
    You either must use a DSN or create you own server. For the DSN each client must have a mapped driver to the computer with the database. For your own server search the Sun site for JDBC drivers or use RmiJdbc (http://www.objectweb.org/)

  • In UNIX how to set classpath

    I know nothing about UNIX. pls kindly give me some instruction on how to set classpath in UNIX, thanks!

    best way is to set in your .profile (name differs between different shells, but whatever the OS/Shell is, it should starts with . and has a 'profile' string in the name). Try ls -a to find the file, edit it, insert lines like this:
    CLASSPATH=xxxx
    export CLASSPATH
    Use : to seperate different path/files.
    then every time when you log in, the classpath is setted.
    if you already logged in, use the above lines in command line, but it only set class path of the current shell/console.
    anyway, you should learn Unix before you do anything, or you'll have more trouble. do a search in yahoo or google to find on line tuturials, and SUN's Java tuturial has some basic instructions on how to use Java in Unix.

  • How to set color for a tabstrip in BSP

    Hello all,
    Can anyone please let me know how to set color for a tabstripn in BSP?
    I am using the below syntax but it still gives me the default color.
    <htmlb:content design="design2003" >
      <htmlb:page title="test " >
        <htmlb:form>
    <htmlb:tabStrip id         = "TabStrip"
                          bodyHeight = "200"
                          bodyColor  = "red"
                          width      = "700" >
    </htmlb:tabStrip>
    </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    Thanks,
    Sandeep

    Hi...
    The below code is working fine for me...
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="stg " >
        <htmlb:form>
          <htmlb:tabStrip width      = "430"
                          bodyColor  = "rgb(88,5,64)"
                          id         = "t1"
                          bodyHeight = "112" >
            <htmlb:tabStripItem id      = "t1"
                                index   = "1"
                                title   = "Sales"
                                tooltip = "My Tooltip for Tab 1" >
              <htmlb:textView text="Tab N 1" />
              <htmlb:tree id        = "treeReports"
                          showTitle = "true"
                          table2    = "<%= mt_nodes %>"
                          title     = "Menu"
                          width     = "100%" />
            </htmlb:tabStripItem>
            <htmlb:tabStripItem id      = "t2"
                                index   = "2"
                                title   = "Production"
                                tooltip = "My Tooltip for Tab 2" >
              <htmlb:textView text="Tab N 2" />
            </htmlb:tabStripItem>
          </htmlb:tabStrip>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>

  • How to set optional for table structure in functiona module

    hi experts,
    as i have small doubt regarding
    while publishing web service by using rfc where i am unable to set optional for table structure i am able to put optional for import parameters may i know how to set optional for table structure ....
    reagrds prabhanjan

    Ignoring the TABLES/CHANGING/EXPORTING argument...
    while publishing web service by using rfc where i am unable to set optional for table structure i am able to put optional for import parameters may i know how to set optional for table structure
    Why not?  There's no issue with marking a TABLES interface parameter with 'Optional' and publishing the function module or function group as a web service...

Maybe you are looking for

  • File to Proxy Scenario : Error in communication channel monitoring

    Hi, I have developed File to Proxy Scenario on PI 7.1 system and it is not working. I see the below error in communication channel monitoring. u201CError: com.sap.engine.interfaces.messaging.api.exception.ConfigException: Some of the IS access inform

  • How to create account group in mass

    Hi, is there anybody who knows a BAPI to create account group, this process is normally made from KDH1, but I want to create a thousound of groups and i think that the best way is an ABAP program. Regards.

  • Country CAO - Alternative Account

    Hi, For a Country specific requirement, I have created Country Chart of Account. Assigned to Co. Code in OB62. Created GL in CCAO. Mapped these in Operating GL Master as alternative account number. Now, the problem is that I don't know how to view an

  • Co-Product partial Qty. processing.

    Hi, I have incorporated a Co-Product Scenario here at client end. This is a Injection Mold Processing company, they have a scenario where in there are 2 products being generated with a single PRT on the same machine, i.e. a Co-Product scenario. Prodn

  • FTP to database not working Oracle 9.2

    Going through the steps of setting up the basic XDB demo. I have setup the listener correctly with the FTP and HTTP presentation and ports. When I use FTP in DOS to try and connect to XDB it immediately opens and then closes communication port. There