Connecting to a database inside a JAR?

Hi,
Can I do the following:
Connect to flatfile database inside the same jar as my program? i.e., would something along the lines of:
jdbc:jar://db.txt
work? And if so, what would be the correct way to do it, other than my horrible example above. If so, what database/jdbc driver can i use for it?
Thanks in advance for all help!
Stu

You could retrieve the data but your gonna have problems when it comes time to update.

Similar Messages

  • 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.

  • Accessing a Derby database inside of a Jar file...

    Hello,
    I've browsed many threads that touch on aspects of this topic, but I still can't seem to figure this out. Here is my dilemma:
    [1] I have a simple application that stores some data using JavaDB.
    [2] Everything works fine when I bundle the app into a jar, as long as I leave my Database folder outside the jar
    [3] If I include the DB in the jar the app does not see it.
    [4] I can't just leave the folder outside the jar because I eventually plan on deploying the app as a Web Start program.
    The Dev guide on JavaDB says +"A database can be in one of many locations: in the current working directory, on the classpath, in a JAR file..."+, and this apparently can be set using the derby.system.home property. I currently use the following to set this property: System.setProperty("derby.system.home", ".myDatabase"); How would I need to change this to allow the app to find the database inside the jar? If this requires the DB to be read-only (which is fine with me), what properties need to be set to designate the DB as such?
    Any input would be greatly appreciated.

    Well, upon rereading the Derby Developer's Guide I found the information I sought in the section "Creating Derby databases for read-only use" (p.34-37). I'm still not 100% sure about how to do the Web Start implementation, but this should put me on the right track.
    [UPDATE IN CASE ANYONE STUMBLES UPON THIS THREAD] It seems that the issue with Web Start is that the database needs to be access a writable location for the temporary directory, so I presume web start would have to request disc-access privileges... something I'm trying to avoid.
    Edited by: CommanderSalamander on Nov 9, 2007 10:06 AM

  • Database in a jar file

    I have an application packaged in a .jar executable. It connects to an Access database using the JDBC-ODBC bridge, so I have the data source set up on my PC, all this works fine.
    My question is how would I go about putting the database into the .jar executable so my files can access it without a user haveing to set up a datasource on thier PC?
    Thanks for any help

    I don't think you are going to be able to reach into a jar and do random access to one of the files inside of it. That's essentially what databases do. So while you might be able to put an .mdb file into a zip, you are going to have to get it out and onto the users hard drive to do anything with it.
    Here's a link which talks a little about that (and web start too)
    http://forum.java.sun.com/thread.jsp?forum=38&thread=242403
    Now that you have an access file, you've got to talk to it. If you don't want to have a DSN, you can either go DSNless
    http://forum.java.sun.com/thread.jsp?forum=31&thread=297824
    or use an MSaccess JDBC driver
    http://servlet.java.sun.com/products/jdbc/drivers

  • Problem: Enterprise Manager is not able to connect to the database instance

    Hello,
    I've got problem with EM. When I try to connect to it I get the following error:
    Enterprise Manager is not able to connect to the database instance. The state of the components are listed below.
    Database Instance, Listener and Agent are all green.
    Few more information:
    OS: Win7 64 bit
    -installed loopback adapter. I can ping my computer name (J-PC) without problem and it pings back 10.10.10.10 address.
    -I have set the ORACLE_HOME and ORACLE_SID env variables
    -I can login to sqlplus with sysman account
    -emctl status dbconsole shows that the EM 11g is running
    I've been struggling for some time trying to get EM running as it should, but no luck so far.
    If you need any more info, do ask. Tnx.

    Hi,
    Regarding causes:
    1. This is inside listener.ora file:
    SID_LIST_LISTENER =
    +(SID_LIST =+
    +(SID_DESC =+
    +(SID_NAME = CLRExtProc)+
    +(ORACLE_HOME = C:\app\J\product\11.2.0\dbhome_1)+
    +(PROGRAM = extproc)+
    +(ENVS = "EXTPROC_DLLS=ONLY:C:\app\J\product\11.2.0\dbhome_1\bin\oraclr11.dll")+
    +)+
    +)+
    LISTENER =
    +(DESCRIPTION_LIST =+
    +(DESCRIPTION =+
    +(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))+
    +(ADDRESS = (PROTOCOL = TCP)(HOST = J-PC)(PORT = 1521))+
    +)+
    +)+
    ADR_BASE_LISTENER = C:\app\J
    ...and this is examples of errors in emoms.trc:
    +2012-05-25 00:29:28,782 [HTTPThreadGroup-49] ERROR conn.ConnectionService verifyRepositoryEx.891 - Invalid Connection Pool. ERROR = Locale not recognized+
    +2012-05-25 00:29:28,798 [HTTPThreadGroup-49] ERROR eml.OMSHandshake processFailure.806 - OMSHandshake failed.(AGENT URL = http://J-PC:3938/emd/main)(ERROR = INTERNAL_ERROR)(CAUSE =java.sql.SQLException: Locale not recognized)+
    +2012-05-25 00:29:28,860 [HTTPThreadGroup-49] ERROR conn.ConnectionService verifyRepositoryEx.891 - Invalid Connection Pool. ERROR = Locale not recognized+
    +2012-05-25 00:29:28,872 [HTTPThreadGroup-49] ERROR eml.OMSHandshake processFailure.806 - OMSHandshake failed.(AGENT URL = http://J-PC:3938/emd/main)(ERROR = INTERNAL_ERROR)(CAUSE =java.sql.SQLException: Locale not recognized)+
    +2012-05-25 00:29:40,908 [HTTPThreadGroup-49] ERROR conn.ConnectionService verifyRepositoryEx.891 - Invalid Connection Pool. ERROR = Locale not recognized+
    +2012-05-25 00:29:40,924 [HTTPThreadGroup-49] ERROR eml.OMSHandshake processFailure.806 - OMSHandshake failed.(AGENT URL = http://J-PC:3938/emd/main)(ERROR = INTERNAL_ERROR)(CAUSE =java.sql.SQLException: Locale not recognized)+
    +2012-05-25 00:29:52,811 [SystemThreadGroup-8] ERROR app.SessionObjectManager sessionDestroyed.128 - java.sql.SQLException: Locale not recognized+
    java.sql.SQLException: Locale not recognized
    2.
    Running lsnrctl status:
    Alias LISTENER
    Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Produ
    ction
    Start Date 25-MAY-2012 07:54:17
    Uptime 0 days 0 hr. 21 min. 25 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File C:\app\J\product\11.2.0\dbhome_1\network\admin\listene
    r.ora
    Listener Log File c:\app\j\diag\tnslsnr\J-PC\listener\alert\log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=J-PC)(PORT=1521)))
    Services Summary...
    Service "CLRExtProc" has 1 instance(s).
    Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "orcl" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB" has 1 instance(s).
    Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully
    Tnx for the help.

  • Unable to connect to local database ( without using tnsname )

    hi guys
    i have 2 database running on local machine.
    db1 SID - orcl (install 1st)
    db2 SID - unicode (install later)
    Today i shutdown unicode database and stop its respective services.
    on dos
    i done a sqlplus scott/tiger, i got an error
    ORA-12560: TNS:protocol adapter error
    therefore
    i done a
    set ORACLE_SID=orcl
    and i still get the same error.
    Therefore i done the another way round. I shutdown orcl database, stop its services and STARTED unicode database and its services.
    I have remove the ORACLE_SID enviroment variable.
    Now, i issue in command prompt
    sqlplus scott/tiger
    i am connected to the unicode database!
    Now i shutdown unicode database and startup ORCL database..
    and i issue a
    sqlplus scott/tiger@ORCL..
    I HAVE No problem connecting to it..
    May i know why do i have to provide the TNSname for ORCL database and i do not have to for the UNICODE database..
    Both are local on my database.
    what is wrong ?
    by the way, i am on XP.
    thanks!

    hi paul,
    sorry for the late reply.
    I was out of town this weekend.
    thank you so much for replying..
    Here is my test results.
    inside command prompt
    (started both services - OracleServiceOrcl and OracleServiceUnicode)
    set ORACLE_SID=orcl
    sqlplus / as sysdba;
    sys@orcl> exit
    set ORACLE_SID=unicode
    sqlplus / as sysdba;
    sys@unicode> exit
    Well, if i explicity set the ORACLE_SID, it works..
    So out of curiousity, i done this testing..
    1) connect to both database and shut them down
    2) stop their services
    3) start only ORCL service
    4) close and reopen command prompt to remove the ORACLE_SID enviroment var
    sqlplus / as sysdba;
    Error: ORA-12560: TNS: protocol adapter error
    ok..
    5)now i stop the ORCL service
    6) and i start the UNICODE service
    then i issue
    sqlplus / as sysdba;
    sys@unicode>
    I have got no local or two_Task variable set, i have got no oracle_sid, nor oracle_home environment variable set.
    Any idea paul ?
    Hope to hear your advice.
    Best Regards,
    Noob

  • Error during database connection to the database : MS SQL Server 2008 R2

    Hi All,
    I am working with ABAP Proxy to Rec JDBC( Integrating XI with MS SQL Server 2008 R2). I am using SAP PI 7.0
    I am getting error in RWB at communication channel monitoring :
    Error during database connection to the database URL 'jdbc:microsoft:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST' using the JDBC driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver': 'com.sap.aii.adapter.jdbc.sql.DriverManagerException: Cannot establish connection to URL 'jdbc:microsoft:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST': SAPClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver'
    I have given Connection details at Rec JDBC Communication channel as :
    JDBC Driver as : com.microsoft.jdbc.sqlserver.SQLServerDriver
    Connection : jdbc:sqlserver://10.1.92.111:1433;database=XONTUSERVENTURA_ORG_TEST.
    Please help me in this regard. I really appreciate your valuable information and time.
    Thanks and Regards,
    Ayub.
    Edited by: Ayubsajjid on Feb 15, 2012 8:49 AM

    Hi All,
    Thanks for all your valuable inputs on my question...
    As per all your inputs, we have to install/Deploy the below required jar files in the aii_af_jmsproviderlib.sda file
    ojdbc14.jar
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Can you please tell me from where we will exact this .jar file, bcoz we have search lotzz but we helpless.
    We install from this link http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=21599--> we download sqljdbc_3.0.1301.101_enu  file >sqljdbc_3.0>enu-->in that I find sqljdbc.jar and sqljdbc4.jar files only . I cant above said .jar files.
    Please help me.
    Regards,
    Ayub.

  • Connect to the database of auto Hosted App on Office 365

    Hi All,
    I developed a custom Application for SharePoint on top Office 365 in Auto-hosted mode. The application has SQL database which will be deployed to SQL Azure.
    I would like to read some info from the database but using another tools not from inside the developed application (e.g. SharePoint designer, PowerPivot) to generate some reports.
    When I try to connect to the database after the application installation using SharePoint Designer I get the following error message:
    Cannot open server 'xxxxxxxxxxx' requested by the login. Client with IP address '41.239.166.230' is not allowed to access the server.  To enable access, use the Windows Azure Management Portal or run sp_set_firewall_rule on the master database to create
    a firewall rule for this IP address or address range.  It may take up to five minutes for this change to take effect.
    Login failed for user 'db_c6ab7aa1_4572_4d36_b99d_741dee28a139_dbo'.
    This session has been assigned a tracing ID of 'c13ecefa-6aa2-4154-86f8-18d272c73b86'.  Provide this tracing ID to customer support when you need assistance. (Microsoft SQL Server, Error: 40615)
    And since I am using the Autohosted mode, I don;t have he Windows Azure Management Portal. is there a workaround for this issue?
    Kind Regards,
    Thanks in advance for you help. Mahmoud

    Hi m_3ryan,
    The error message shows you need to add your IP Address to the firewall rules of the SQL Azure to get yourself connected. As you deploy the database to SQL Azure, you mean you cannot open window azure management portal?
    Follow the steps in below article, check whether it works:
    How to: Set Firewall rule to connect to SQL Azure – sp_set_firewall_rule:
    http://azure-howto.blogspot.com/2011/05/how-to-set-firewall-rule-to-connect-to.html
    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Qiao Wei
    TechNet Community Support

  • Report tries to connect to wrong database

    Hello,
    We're currently developing an ASP.NET C# Web Application and integrate some Crystal Reports using the CrystalReportViewer control. Our environment looks like this:
    <h1>Dev Environment:</h1>
    One machine using
    - Windows Server 2003
    - .NET Framework 3.5 SP1
    - IIS 6
    - SQL Server 2008 Developer Edition, Default instance
    - Crystal Reports 2008 (no service packs applied so far)
    <h1>Production Environment:</h1>
    One machine using
    - Windows Server 2008
    - .NET Framework 3.5 SP1
    - IIS 7
    - SQL Server 2008 Express Edition, Named instance
    I've designed the report on the Dev Environment. For this I created a new database connection inside the report to the Dev Database. We use OLE DB for SQL Server to connect to the database using sql authentication. We pass the login credentials in code. The report uses two sql server views and one sql table to display its data. The report is configured to not store data inside.
    To pass the login credentials, we use the same code as recommended in your code samples on https://www.sdn.sap.com/irj/boc/samples:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Configuration;
    using CrystalDecisions.Shared;
    namespace Ispin.Irma.Helpman
        public partial class ShowReport : System.Web.UI.Page
            protected void Page_Init(object sender, EventArgs e)
                ConfigureCrystalReports();
            private void ConfigureCrystalReports()
                string ReportPath = Server.MapPath("ReportCallTimeUsage.rpt");   
                ConnectionInfo connectionInfo = new ConnectionInfo();
                connectionInfo.ServerName = "ANANKE\\SQLEXPRESS";
                connectionInfo.DatabaseName = "Irma";
                connectionInfo.UserID = "<username goes here>";
                connectionInfo.Password = "<password goes here>";
                CrystalReportViewer1.ReportSource = ReportPath;
                SetDBLogonForReport(connectionInfo);
            private void SetDBLogonForReport(ConnectionInfo connectionInfo)
                TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
                foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
                    tableLogOnInfo.ConnectionInfo = connectionInfo;
    <h1>Problem:</h1>
    When deploying the application and reports to the production environemt, the reports come up with a login window, forcing me to enter login credentials to the dev database. At this point I can only change the username and passwort fields, but not the server or the database. So, I'm unable to enter the correct login data to connect to the production system since this is on another machine.
    <h1>What I already did:</h1>
    - Install Crystal Reports 2008 runtime on production webserver (this helped, but the login problem still arises). I got the runtime from https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm, I've choosen the "Crystal Reports 2008 - Redistributable Installation" file, published on 10.09.2008.
    - Install Crystal Reports 2008 Trial Edition on production server (I could start the report sucessfully out of the designer using the login credentials for the productive database server).
    It seems that the code for passing the credentials at runtime is not effective. It looks as if the report is saving login credentials inside the rpt file. but why? It must be possible to pass login credentials by code. Can you please provide me additional hints for getting this thing to work?
    Thank you very much.
    Edited by: AndreG on Aug 9, 2009 3:41 PM
    Code formatting seems not to work.... sorry.

    Lots of posting for this same question. Please search before posting the same question again.

  • I can't connect to MySQL database from The JSP Standard Tag Library

    Hi All !
    I have a problem, please help me anybody !
    I don't connect to MySQL database from jsp page using JSTL tag but from servlet all work correctly. I set my path and put �mysql-connector-java-3.1.13-bin.jar� in ENVIRONMENT WinXP(classpath=C:\Java\jdk1.5.0_10\jre\lib\ext\mysql-connector-java-3.1.13-bin.jar) and in War project folder �WEB-INF/lib� and in [TomcatServer]\common\lib.
    I have in folder�WEB-INF/lib� following files:
    antlr.jar
    commons-beanutils.jar
    commons-collections.jar
    commons-digester.jar
    commons-fileupload.jar
    commons-logging.jar
    commons-validator.jar
    jakarta-oro.jar
    jsf-api.jar
    jsf-impl.jar
    jstl.jar
    mysql-connector-java-3.1.13-bin.jar
    standard.jar
    struts.jar
    I'm using:
    NetBeans 5.5 Build200610171010 (bundled Tomcat 5.5.17)
    Ent.Pack 20061020 Visual Wb Pack 061103
    OS WinXP SP2
    Java 1.5.0_10
    MySQL 5.0.18-nt
    1:<%@page contentType="text/html"%>
    2:<%@page pageEncoding="UTF-8"%>
    8: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    9: <%@taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>
    10:
    11: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    12: "http://www.w3.org/TR/html4/loose.dtd">
    13:
    14: <sql:setDataSource var="ds"
    15: driver="com.mysql.jdbc.Driver"
    16: url="jdbc:mysql://localhost:3306/test"
    17: user="root"
    18: password="xxxx"/>
    19:
    20:
    21:<sql:query sql="select name, age from People" var="res"
    22: dataSource="${ds}"/>
    I have received report on mistake when entered code at the top:
    �/index.jsp [21;0] According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions�
    I used instead of (dataSource="${ds}")->(dataSource="ds") but this did not work.
    After build and run I have received
    =========================================START=================================
    HTTP Status 500
    type Exception report:
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    org.apache.jasper.JasperException: /index.jsp(21,0) According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146)
    org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955)
    org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
    org.apache.jasper.compiler.Validator.validate(Validator.java:1489)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:166)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    =======================================END================================
    Error: "According to TLD or attribute directive in tag file, attribute dataSource does not accept any expressions" - but according to documentation such parameter possible.
    BUT WHEN JOINING With DATABASE FROM SERVLET ALL WORK FINE.
    I read this doc - [http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html], this applicable if I Tomcat Admin, but i'am not Admin
    I simply user, i.e. I want to place its database on virtual host (Tomcat+(JSP-JSTL)+MySQL).
    There is idea how can resolve this problem
    Thank you in advance ;)

    For all how have similar problem.
    Decision instead of these ways
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    it is necessary to indicate these
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

  • How can I connect to a database using Java Web Start?

    When I run the application without Java Web Start, the program can get the driver and connect to the database. However, when I try to use this same application with Java Web Start, the program can not load the driver. Why is this happening? I am using a mySql database driver.

    I assume you are trying to connect using JDBC, are did you include the jdbc jar in your resources ?

  • Trouble connecting to mySql database

    Hi Forum
    I have a site hosted with Godaddy, and have created a database, but I can not connect to the database with DW.
    1)  I made made sure that the invisible file _mmServerScripts folder and the Connections folder are present both on my local machine in the root directory and on the server.
    2) I can connect to the hosting account with FTP.
    3) I can connect to the database via Goddaddy and PHPadmin.
    3) I have pointed the test server to the same url as the hosting account but to a folder in the directory that is called test_server.
    (I have used this approach before, and it worked then)
    4) I have tried to log on with the URL that PHP admin tells me: http://nbst.db.6113589.hostedresource.com/ and also with http://173.201.136.50
    5) I am getting the standard error code 404 suggesting:
    "a) There is no testing server running on the server machine
    b) The testing server specifed for this site does not map to http://173.201.144.128/_mmServerScripts/MMHTTPDB.php Url. Verify that the URL Prefix maps to the root of the site. "
    6) The error message refers to 173.201.144.128. This is an unknown IP to me. The database is supposed to be at  173.201.136.50
    What am I doing wrong??
    ggaarde

    ClassNotFoundException means the driver isn't loaded. "No suitable driver" usually tells me that the syntax in the connection URL is incorrect for some reason.
    Make sure you have an up to date driver JAR:
    http://www.mysql.com/products/connector/j/
    The driver class name should be com.mysql.jdbc.Driver
    %

  • Connecting to a database on a hosted site

    I have a mysql database on the site where my web page is hosted.
    I would like to write an application that sits on a users computer and allows them to send data to this database. Ther server has a firewall and its linux.
    How would anyone suggest I do this.
    How would I connect to the database ?
    Would I need JDBC?
    if so what would the connection look like ie
    connection con = DriverManager.getConnection( url, "mylogin", "thepassword");
    what would url =?
    look forward to hearing from you
    Gina1234

    I would like to write an application that sits on a
    users computer and allows them to send data to this
    database. Ther server has a firewall and its linux.
    How would anyone suggest I do this.
    How would I connect to the database ?I s'pose the JDBC code could be called from a server-side component (like servlet). This will prevent the users from requiring the driver JAR on their computers.
    Would I need JDBC?Yes.
    if so what would the connection look like ie
    connection con = DriverManager.getConnection( url,
    "mylogin", "thepassword");
    what would url =?Check the MySql driver documentation. A quick Google search would also give the connection URL.

  • 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.

  • Connect applet to database using JDBC

    I try to connect Applet to database, but have error:
    Access denied (Java.lang.Runtime.Permission access Class In paclage.sun.jdbc.odbc)
    I think the reason is the security issue, but how to implement the security issue in the code?
    Help me...

    If you aren't using the plugin, changing the policy file for the Java Runtime Environment (JRE) won't do anything. Changing the policy file and signing the applet are two ways of granting an applet permission. I only use changing the policy file for testing purposes. I broke down and bought a certificate after I realized I would have to change the policy file on hundreds of machines, and do it again if the server changed.
    You sound like you should be using the plugin. Appletviewer knows about the JRE and uses it. You need to change your HTML to use EMBED and OBJECT tags instead of APPLET tags (use HTMLConverter).
    sun.jdbc.obdc.JdbcOdbcDriver is in rt.jar, which is in /Prog Files/Javasoft/JRE/1.3???/lib and is installed when the pluggin is installed (which happens automagically when using the EMBED and OBJECT tags). It was also loaded on your development machine when you installed the SDK.
    You can remove the need to sign the applet to test whether this is a security problem or machine configuration problem. If you copy the .html and .class files to a directory on a machine you expect it to run on, start your browser and type 'C:\MyDirectory\MyApplet.html' in the address bar. Applets loaded locally are granted all permissions.

Maybe you are looking for