Connecting to JDBC with jar

I have downloaded the MySQL JDBC from their site and have a jar file. It is called
mysql-connector-java-3.1.13- bin.jar
I would like to have my NetBeans IDE 4.1 recognize this so I can write java code. It does not recognize the class currently.
I tried adding it to the IDE path
going to the web project, right click for properties.
Choose libraries
Choose the tab that says "compile tests"
Then, I click "add jar/folder" and browse to the jar file
Then choose the tab that says "run tests"
Then I click "add jar/folder" and browse to the jar file
Now I would assume this would be added to my class path for startup
but it doesnt work
Any ideas

I do have the database linked in to my "Databases" with a driver listed under this list. Which is why I do not comprehend why my jsp code can not find the driver itself.
Here is the error I get:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.gjt.mm.mysql.Driver
     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
     org.apache.jsp.index_jsp._jspService(index_jsp.java:183)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
root cause
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
     org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:150)
     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71)
     java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
     java.lang.Class.forName0(Native Method)
     java.lang.Class.forName(Class.java:164)
     org.apache.jsp.index_jsp._jspService(index_jsp.java:60)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.7 logs.When I right click on "MySql" under drivers I get the name
org.gjt.mm.mysql.Driver
so my code now appears as:
<%@page import="java.sql.*" %>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<%
   Connection connection = null;
   Statement statement = null;
   ResultSet rs = null;
%>
<% Class.forName("org.gjt.mm.mysql.Driver").newInstance();
//org.gjt.mm.mysql.Driver
    connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/database01", "user", "password");
       statement = connection.createStatement();
       rs = statement.executeQuery("SELECT * FROM table01");
       while (rs.next()) {
        out.println(rs.getString("field01")+"<br>");
  %>Any ideas welcome.. I have been searching through this link
http://www.netbeans.org/kb/50/using-netbeans/configuring.html
Without a lot of luck. I am using 4.1

Similar Messages

  • Problem connecting JDBC with SQLServer 2005

    * While executing the following JDBC code with SQLServer 2005, it throws Exception
    * I dont wts wrong in my code, (Note: I have included the sqljdbc.jar in my path)
    * Pls let me know the problems in my code
    * Thanks, Following is my code and error
    CODE:
    import java.sql.*;
    public class JDBCwithJava {
         public void work() {
               // Create a variable for the connection string.
               String connectionUrl = "jdbc:sqlserver://localhost:1433;" +"databaseName=empdb";
               // Declare the JDBC objects.
               Connection con = null;
               Statement stmt = null;
               ResultSet rs = null;
               try {
                    //Load the driver
                  Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                  // Establish the connection.
                  con = DriverManager.getConnection(connectionUrl);
                  System.out.println("Database Successfully Connected...!");
                  //Connection Info
                  DatabaseMetaData dm = con.getMetaData();
                 System.out.println("Driver Information");
                 System.out.println("\t Driver Name: "+ dm.getDriverName());
                 System.out.println("\t Driver Version: "+ dm.getDriverVersion ());
                 System.out.println("\n Database Information ");
                 System.out.println("\t Database Name: "+ dm.getDatabaseProductName());
                 System.out.println("\t Database Version: "+ dm.getDatabaseProductVersion());
                  // Create and execute an SQL statement that returns some data.
                  String SQL = "select  * from emptable";
                  stmt = con.createStatement();
                  rs = stmt.executeQuery(SQL);
                  // Iterate through the data in the result set and display it.
                  while (rs.next()) {
                     System.out.println(rs.getInt(1) + " " + rs.getString(2));
               // Handle any errors that may have occurred.
               catch (Exception e) {
                  e.printStackTrace();
               finally {
                  if (rs != null)
                       try {
                            rs.close();
                      catch(Exception e) {
                  if (stmt != null) try { stmt.close(); } catch(Exception e) {}
                  if (con != null) try { con.close(); } catch(Exception e) {}
         public static void main(String ar[]){
              JDBCwithJava call = new JDBCwithJava();
              call.work();
    OUTPUT with ERROR:
    com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host  has failed. java.net.ConnectException: Connection refused: connect
         at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
         at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
         at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
         at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
         at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at JDBCwithJava.work(JDBCwithJava.java:17)
         at JDBCwithJava.main(JDBCwithJava.java:58)* Please give me your suggestion about the above program.........

    JavaImran wrote:
    RoyGrini wrote :
    Looks like login problems. Username/password or windows authentication logon problem.        * I didnt give any UN and Pwd for my database.........And the
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)gives you a 'connection refused'
    Try with providing a SQL username/password. Maybe that will work
    - Roy

  • JDBC with MSSQL 2005 -- problem connecting

    Hi, I have setup JDBC and I am able to connect to a MySQL database just fine. But I can't connect to MSSQL SQLExpress 2005.
    I got the sqljdbc.jar file placed it under the LiveCycle8\jboss\server\all\lib folder and setup the Datasource file as:
        MSSQLDS    jdbc:sqlserver://LIVECYCLE\SQLEXPRESS:1433;databaseName=MyDBName
    com.microsoft.sqlserver.jdbc.SQLServerDriver
        username
        password
             MS SQLSERVER2005
    Then I modified the login-config.xml and added the application-policy as:
                   username
                   password
                   jboss.jca:service=LocalTxCM,name=MSSQLDS
    Then in LC connection, setup the string to java:/MSSQLDS
    When running the test query b I get NO Response At All.  And I mean, even if I intentionally change the datasource file to hold incorrect information, I'll get no response. However, I can connect to MySQL without any problems.
    b Any ideas?
    Thanks for any help!

    JavaImran wrote:
    RoyGrini wrote :
    Looks like login problems. Username/password or windows authentication logon problem.        * I didnt give any UN and Pwd for my database.........And the
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)gives you a 'connection refused'
    Try with providing a SQL username/password. Maybe that will work
    - Roy

  • Problem with Progress DB while using to connect using JDBC Adapter

    Hi,
      I am facing Problem with Progress DB while using to connect using JDBC Adapter. I am getting the following error in auditlog file like,
    Error during database connection to the database URL  jdbc:JdbcProgress:T:156.5.31.65:2545:/mfgprodev/devbadb 
    /devsche/i_apoext.db using the  JDBC driver "com.progress.sql.jdbc.JdbcProgressDriver" : com.sap.aii.adapter.jdbc.sql.DriverManagerException: Unable to locate a suitable JDBC driver to establish a connection to URL " jdbc:JdbcProgress:T:156.5.31.65:2545:/mfgprodev/devbadb 
    /devsche/i_apoext.db "
    I tried using the following all URLs,
    1. jdbc:JdbcProgress:T:156.5.31.65:2545:i_apoext.       
    2. jdbc:JdbcProgress:T:156.5.31.65:2545:i_apoext.db     
    3.                                                      
    jdbc:JdbcProgress:T:156.5.31.65:2545:/mfgprodev/devbadb 
    /devsche/i_apoext.                                      
    4.                                                      
    jdbc:JdbcProgress:T:156.5.31.65:2545:/mfgprodev/devbadb 
    /devsche/i_apoext.db.                                  
    Can anyone please help me out in solving this issue.
    May be the cause for this is :
    1) The Wrong URL  format
    2) CLASSPATH is not setted properly..
    Can you look more into this stuff.
    Thanks,
    Soorya.

    Hi,
    To access any database fromm XI, using the JDBC adapter, the corresponding drivers have to be installed on the XI server.
    Just check this note 831162.
    Also, check this PDF to install Drivers in XI,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3867a582-0401-0010-6cbf-9644e49f1a10

  • How to create JDBC connection in J2ME with MS-SQL server?

    I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........

    I need to have database connection in PDA with SQL server,as i am new to J2ME ,i dont know how to create jdbc connection on J2ME device.Please help me out with this problem........

  • How to connect mySQL database with jdbc

    Who can tell me how to connect mySQL database with jdbc? Thanks

    http://onesearch.sun.com/search/developers/index.jsp?and=connect+mysql&nh=10&phr=&qt=&not=&field=title&since=&col=devforums&rf=0&Search.x=24&Search.y=16

  • Error connecting jdbc with SQL server

    Hi,
    I get the following error when I try to run a sample program to connect SQLserver with JDBC . The driver I used to connect is " com.microsoft.jdbc.sqlserver.SQLServerDriver ".
    I have registered the driver properly but have problem in connecting to JDBC.
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to connect. Invalid URL.
    at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source
    at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
    at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at Test.main(Test.java:12)
    pls help
    Thanks in advance

    Well there is something wrong with your database URL you are giving to the driver. You should lookup the documentation for the driver and see what format the URL should be in.
    Here is an open source driver you could try too -- http://jtds.sourceforge.net/

  • I need Help for Connect To DB2 with JDBC

    I'd like to know why I Have this problem.
    The DB2 v 5.10 is in a IBM OS/390
    I know the IP, PORt, DBNAME and I'd like to connect to DB2 with my windows XP using JDCB from IBM.
    I use JDBC Universal for DB2 type 4.
    Class.forName("com.ibm.db2.jcc.DB2Driver");
    Url = "jdbc:db2://IP:PORT/BDNAME";
    DriverManager.getConnection.... (url, user, pass)..
    If I execute this, I have next problem
    SQL state = null
    Error code = -4499
    There is no available conversion for the source code page, 1208, to the target code page, "". DB2ConnectionCorrelator: null
    Why is this?
    Finally, the web application will running in a AIX IBM with machine, It could be that this machine (aix) can connect with the IBM OS/390 with JDBC for iBM?
    Thankss!!!

    Check how you configured the IP on the laptop and computers, assigned by router with DHCP feature enabled? Or configure manually? If it's assigned by wireless router, then make sure you assign big enough IP range in DHCP setting. Take a look on using ping to troubleshoot network and wireless router configuration articles to help you more..

  • Connecting Oracle 8i with JDBC

    Hi Friends,
    I am facing a problem while doing a connection to my DB which is ORACLE 8i with JDBC communication channels thorugh xi.
    I am getting an error "Error during database connection to the database URL 'jdbc:oracle:thin:@hostname:ORCL' using the JDBC driver 'oracle.jdbc.driver.OracleDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:oracle:thin:@hostname:ORCL': SAPClassNotFoundException: oracle.jdbc.driver.OracleDriver"
    In one of the SAP notes:867176 its mentioned .....
    3. Which JDBC driver version is certified to connect to which database version?
                  From the Oracle side:
                  The Oracle 10g JDBC drivers are certified to work with currently-supported versions of the database.
                  JDBC 8i/9i Thin drivers are certified to work with supported (previous) versions of the database.
                  Existing and supported JDBC drivers are certified to work with Oracle Database 10g.
                  From the SAP side:
                  SAP only supports homogeneus setups. The oracle driver major version must match the database major version, and the driver version must not be smaller than the database version.
                  SAP does not support Oracle 8i drivers.
    Is it not possible to connect to my DB?  Is SAP supports the connection to 8i oracle database? any idea,,,
    Regards,
    Sunil.

    Hi,
    Following is the connection string that we are currently using for connecting to Oracle 8i.
    This setting has been working for us. give it a try.
    connection string : jdbc:oracle:oci8:userid/password@server
    Note that this connection string is only if you use the Oracle OCI driver. The OCI driver requires a shared library or DLL on the server.
    The thin driver for Oracle is more commonly used as it doesn't require any additional libraries. The connection string is as already listed above:
    jdbc.oracle.thin:@server:port:SID
    There is no need to put the user and password into the connection string in the adapter config, putting it into the user and password fields works just fine.
    Regards,
    Suryanarayana

  • JDBC - Connection is busy with hstmt

    Dear Friends,
    I have created a function with three Statements and three Resultsets, each resultset for each separate statement to execute a select query and have proper close methods too.
    I am executing this function in JComboBox ItemListener. I am getting the error..."Connection is busy with another hstmt"...
    I am using Java Swing with MS SQL Server...
    I solved this error by proper closing of resultsets and statements. But i can't when i call this in itemlistener. can anyone help me pls....
    Regards,
    V.Prasanna

    Try:
    Connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    I had good luck with it to solve the same problem. I read somewhere that this is forcing the connection to create a new cursor etc...
    ming

  • Error trying to connect via jdbc

    I'm trying to connect via jdbc driver from a java application to a remote db. The code is quite simple
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@dbhost:orcl", "user", "password");
    in my CLASSPATH I have the ojdbc14.jar file
    When I run this program I get the following error:
    Exception in thread "main" java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
    at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:366
    8)
    at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:353)
    at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:371)
    at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
    va:551)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:351)
    at java.sql.DriverManager.getConnection(DriverManager.java:525)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at Test.main(Test.java:12)
    Please be aware of the following facts:
    1) sqlplus from the same machine has no problem connecting to the db
    2) there is no firewall or router between the client and the server
    3) As host name I've tried the fqdn (resolved by the DNS), a name I've set up in /etc/hosts, the mere IP address
    4) Checking with tcpdump, I've verified that NO network packet actually leaves the client, so the problem completely lies there.
    Has anyone some good idea why this happens?

    Make sure you are providing correct hostname and listener port number

  • How to do connectivity to JDBC on Linux platform

    Hello friends!
    I am novice user of JSP & JDBC. I dont know how to make connectivity with database using JDBC driver and that is using Linux paltform. I read one tutorial for that they have given some code. But they have used <% import java.sql%> . The database I am using is PostgreSQL. So how to do that?
    Plese help me ! Thank you in advance!

    Same as JDBC on any other platform. Java and JDBC are OS independent.
    The java.sql package is part of the JDK, of course. No action required.
    If you're using PostgreSQL, you have to get their JDBC driver JAR and put it in your app's CLASSPATH.
    Then you should review this.
    %

  • Cannot create SOA-MDS connection for JDBC driver issue

    I am unable to create a SOA-MDS connection in JDeveloper 11.1.1.6. We are using MS SQL Server database and have put the sqljdbc4.jar file into a library in our JDeveloper environments. We can use this to sucessfully create database connections.
    However, when we attempt to configure a SOA-MDS connection which uses our DEV_MDS connection (which uses the com.microsoft.sqlserver.jdbc.SQLServerDriver successfully), we do not see anything in the drop down list for 'Select MDS partition'.
    While looking at the Messages, log, we're getting:
    WARNING: Error reading db partitions for connection DEV_MDS. Reason: MDS-0003: error connecting to the database
    Error during pool creation in Universal Connection Pool Manager MBean
    ...ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
    I opened our sqljdbc4.jar file and see both the SQLServerXADataSource.class and SQLServerDriver.class files in there.
    So why can JDeveloper load one of them but not the other at runtime? Do I need to add the sqljdbc4.jar to a second location (besides a custom Library) in order for the Universal Connection Pool Manager MBean to load it via JDeveloper?
    Please advise,
    Michael
    NOTE: I can manually query the database and see 'soa-infra', 'owsm' and 'obpm' partitions just fine.
    Edited by: mscongdon on Aug 14, 2012 9:33 AM

    Hi,
    Do you use MS SQL Server as your MDS database? Did you create an MDS in it using RCU?
    When you created the database connection in JDeveloper could you test it succesfully? Can you connect to it with the Database Navigator?
    Regards,
    Martien

  • JDBC with SQL Server

    Hi,
    I am trying to connect to a SQL server database by giving table name in (SPVC) database as spvc.dbo.tablename.. If i want to access another database (SPVC_D), how can i do it without changing my java code?? Can i be able to add the database name to the connection string and i can remove the hard coding (spvc.dbo.) from my java code?? How shall i be able to do that..
    Please let me know.. I am very new with JDBC with SQL server..
    Thanks
    Praveen Padala

    In the MS SQL Server that I use, the following syntax
    spvc.dbo.tablename
    Breaks done as follows...
    <database>.<user>.<tablename>
    However connections are always to a database. Thus when one uses the above syntax it basically runs 'in' the one database and accesses another.
    Depending on various attributes of the tables, if and only if, a table called 'tablename' exists in a database called 'spvc_d' then if you connect to 'spvc_d' then you can access 'tablename' just by using 'tablename'.
    So if that is what you are doing you will not have a problem.

  • Is it possible to connect Sqlfire server with oracle using DBSynchronizer using default license

    is it possible to connect Sqlfire server with oracle using DBSynchronizer using default license
    Sql fire is my machine
    Oracle is another machine
    When i connect sqlfire with oracle using DBsynchronizer It shows the error message as Wan is not supported for default license
    When i connect Sqlfie(my system) with oracle( another system) using JDBC Rowloader .nothing is happening after some time it shows the error like"time out for pool connection to archive database.When i increase the time out also nothing is happening.
    what is the reason for above two errors(I stated in the pragraph.)
    is it beacuse of wan netwrok not supported by default evaluation license?
    could you please explain?

    I don't think this has anything to do with a VMware product.

Maybe you are looking for