How to use database file within jar archive

Hi. I'm quite new in Java programming, and I'm wondering if what I did makes sense or not.
In my applet I'm using a MS Access Database file, which is contained in the same Jar Archive like the Applet class file. I tried and tried to use this Database file directly but it wouldn't work. Than I read in some other forum that it is not possible to use the database file directly within the archive. First question: Is that true?
Than I desided to extract the DB file in the init() method of my applet to the default temporary foulder. When the program is closed I use the destroy() method to delete it again. Everything works well now. But is this the typical way this is done?
Thanks for help!

Hi,
here is the code which extracts the database file out of the jar archive (the same archive in which the class file is):
//get the user temporary folder
File TempFolder = new File(System.getProperty("java.io.tmpdir"));
//create (empty) db file
efile = new File(TempFolder, "steelSections.mdb");
// if database file is not yet extracted
if (!efile.exists()) {
//get an input stream for the database file
InputStream in = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(
"FaST/db/steelSections.mdb"));
//create an output stream for the db file on the file system
OutputStream out = new BufferedOutputStream(new FileOutputStream(efile));
//-Buffer to copy the data
byte[] buffer = new byte[2048]; //buffer to copy the binary
for (;;) {
int nBytes = in.read(buffer); //read data
if (nBytes <= 0)
break; //no more data to read
out.write(buffer, 0, nBytes); //write data
out.flush(); //close out and in streams
out.close();
in.close();
If you have the db file in an other jar archive file you need a referenze to the entry in the other jar archive. I'm not sure how to get this, but I'm sure you fill find a solution by searching in this forum...
Good luck!

Similar Messages

  • Its urgent  how to use calss file of jar located in lib folder

    how to use calss file of jar located in lib folder.
    i want to use RowSetDynaClass class which is in beanutil jar file which is in my lib folder .if i use that class in my jsp following error is coming.
    Class RowSetDynaClass not found.
    RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
    how to access class in jar file.
    please help

    You have to either refer to the class in its fully quallified name, or import it into the JSP:
    <%
      some.full.packagename.RowSetDynaClass resultSet = new some.full.packagename.RowSetDynaClass(rs,false);
      ...-or-
    <%@ page import="some.full.packagename.RowSetDynaClass" %>
    <%
      RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
      ...As long as the class has public visibility and you have re-started the server/servlet context since you added the JAR.

  • How to use txt files in jar file

    Hi all
    I just made a program that uses a text file, but I havent managed to work it correctly, program runs without jar correctly, but when I packaged all files into a jar, it couldnt find txt file, so I can only run it when I create another text file outside of jar.
    How can I solve this??

    I used this:
    Scanner fileScan = new Scanner (new file
    ("Words.txt"));
    but when I make a jar file, it doesnt find the txt
    file inside a jar,
    do I need to specify path or something?I have already told you that you shouldn't use new File(..) you should use getResourceAsStream(String name) to get an InputStream to the file.
    Kaj

  • How to use properties file

    Hi,
    I want to use properties file in my application. I have kept properties file inside a directory called properties which is inside myProject(which is the parent directory of my project) i.e "myProject/properties".
    My java file where i want to call this properties file is inside the myProject/WEB-INF/src/java.
    How can i call the properties file from myProject/WEB-INF/src/java/PropertyReader.java
    I wrote java program in myProject/WEB-INF/src/java/PropertyReader.java like:::::
    ResourceBundle resBun = ResourceBundle.getBundle("Test", Locale.getDefault()); // Test.properties is inside myProject/properties
    resBun..getString("name");
    After running the program i am getting the following errors:::::
    Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name Test, locale en_US
    at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
    at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:805)
    at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)
    at PropertiesReader.main(PropertiesReader.java:4)
    What is the issue? How to use properties file?
    Waiting for reply.
    Thanks

    Still getting same exception. As you explained i tried like the below:::
    1. I am using ant as build tool.
    2. My properties file is for database configuration
    My properties file is::
    database.properties (inside myProject/properties)
    JDBCDriver=org.gjt.mm.mysql.Driver
    JDBCConnectionURL=jdbc:mysql://pmdbmysql:3306/bandwidthshaper?user=admin&password=admin
    My java package structure is
    WEB-INF/src/java
    WEB-INF/src/classes
    For build WEB-INF is the base directory and build.xml is inside the src directory
    In my build.xml i wrote the following lines for compilation::
              <target name="compile" >
                   <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source">
                        <classpath refid="class.path"/>
                   </javac>
    <copy todir = "src/classes" >
    <fileset dir = "../properties" />
    </copy>
                   <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/>
              </target>
    I am copying properties file to the classes directory.
    Now in java file which is inside /WEB-INF/src/java, I wrote::
    try {
    Properties programProps = new Properties();
    InputStream is = getClass().getResourceAsStream("/database.properties");
    if(is == null)
    throw new IllegalStateException("Properties file missing ");
    programProps.load(is);
    System.out.println("driver name::::::: "+programProps.getProperty("JDBCDriver"));
    is.close();
    } catch(Exception e) {
    e.printStackTrace();
    After compilation in my classes directory i am getting database.properties file and my java file with package.
    At the time of running i am getting "java.lang.IllegalStateException: Properties file missing"
    Now tell me where is the fault. Why again i am getting exception.
    Thanks

  • How to use database look up table function in xsl mapping

    Can anybody tell me how to use database look up table function while mapping xsl between 2 nodes.
    I have an XML file coming in and depending on one of XML elements we need to decide which further path to take. But, using this XML element, we need to query database table, get metadata and accordingly take appropriate path. I have written lookup function which returns metadata value.
    Now, the issue is how do I pass the XML element valu as input to look up function? When I tried to drag it to the input node of lookup function, it throws an error like "Maximum number of parameters exceeded"
    Thanks,

    If the lookup table is always going to remain the same (e.g. a character generator or something similar) you can place the values in a 2D array constant on your diagram, with the input value as one column, the equivalent as the other. When you need to perform the lookup you use an index array to return all the values in the "input column", search it using "search 1D array" and use the resulting index number to index the other column's data. If the values may change, then it would probably be best to load an array control with your equivalent values from a file.
    P.M.
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Access wav-files in jar-archives (URL works, File works not)

    Hi there!
    The un-jar-ed application works fine, but I have a problem with accessing files in jar archives.
    URL url = Classname.class.getResource("testdir/test.wav");works fine (and loading images works this way), but as soon as I try to get the file
    File file = new File(url.getFile());I get an null-exception.
    (in my case, I use the jmf package to play the sound-files, and I get the problem when I try to instatiate the MediaLocator
    MediaLocator mediaLocator = new MediaLocator(url);but I think the problem is the same)
    Thanx for help

    works fine Then keep doing it that way. What's the problem? It's true that you can't access something in a jar archive via a File object, so don't do that.

  • How to use property file - sql query define in property file

    Hi All,
    Anybody please tell me how to use property file.
    I have placed sql query in propery file and I have to access this in my file.
    well so far this is my code but don't know how to implement in the following ...
    pstmt = con.prepareStatement("select * from registration where username=?");
    instead of writting the query I want to use the property file.
    so far I have developed the following code...
    FileInputStream fis = new FileInputStream("querysql.property");
    Properties dbProp = new Properties();
    dbProp.load(fis);is the code correct... or is there another way to access property file
    Please help.
    please reply soon....
    Thanks

    Before answering, check if it's already been done here http://www.jguru.com/forums/view.jsp?EID=1304182

  • How to use XSJS file path in Controller.js file

    Hi Experts,
    Regarding How to use XSJS file path in Controller.js file.
    I have gone through the SAP HANA Extended Application Services (Thomas Jung http://scn.sap.com/community/developer-center/hana/blog/2012/11/29/sap-hana-extended-application-services article.)
    Seems to be there is no information about the same. May be the article is targetted for Beginners and above. As I am a learner I am not able to do the same.
    var aUrl = '../../logic/demo_main.xsjs? (highlighted)
    Suppose my XSJS file is at http://ipaddress:8000/newtest/Func.XSJS.
    Can I use like below
    var aUrl = 'http://ipaddress:8000/newtest/Func.xsjs?
    or
    var aUrl = '../../newtest/Func.xsjs?
    I tried with multiple options but not able to get the expected output.
    Can you please provide more details on this?

    Dear Thomas,
    I am a abap developer , recently we meet a problem on our webdynpro report performnace issue. As in the development, we use SALV_WD_TABLE to design a ALV. and verything work correctly in our DEV system.
    But after when our QAS system, there are more records for the ALV, one of them has 21000 records. And in the layout, we have a column as checkbox.
    If we click any one checkbox, then the layout will respond almost 1~2 minutes. With debug I found the most time cost in the standard program.
    And with search I found that you have solution to solve it as 1,000,000 rows.
    So is it possible to provide some idea or solution to us?
    Many thanks for your help!
    BR
    Vincent Chen

  • Need help on how to use conference facility within adobe connect

    I need some help on how to use conference facility within adobe connect?

    I'd recommend you start here: Getting Started with Adobe Connect - Adobe Connect User Community

  • How to use XML file as a source in BODS?

    How to use XML file as a source in BODS?
    Could anyone please help me out for this?

    exmpale XML file :
    <?xml version="1.0" encoding="utf-8"?>
    <MM_RECON_REPORT>
      <RPT_DATE>str1234</RPT_DATE>
      <RPT_ROW>
        <SRC_EXT_REC_COUNT>123.45</SRC_EXT_REC_COUNT>
        <PRE_TRANS_REC_COUNT>123.45</PRE_TRANS_REC_COUNT>
        <POST_TRANS_REC_COUNT>123.45</POST_TRANS_REC_COUNT>
        <PASS_BAPI_REC_COUNT>123.45</PASS_BAPI_REC_COUNT>
        <TOT_SAP_RETURN>123.45</TOT_SAP_RETURN>
        <TOT_SAP_SUCC_REC_COUNT>123.45</TOT_SAP_SUCC_REC_COUNT>
        <PARTIAL_SUCC_REC_COUNT>123.45</PARTIAL_SUCC_REC_COUNT>
        <TOT_SAP_ERR_REC_COUNT>123.45</TOT_SAP_ERR_REC_COUNT>
        <MM_SUCC_REC_COUNT>123.45</MM_SUCC_REC_COUNT>
        <MM_ERR_REC_COUNT>123.45</MM_ERR_REC_COUNT>
        <CLS_SUCC_REC_COUNT>123.45</CLS_SUCC_REC_COUNT>
        <CLS_ERR_REC_COUNT>123.45</CLS_ERR_REC_COUNT>
        <CP_SUCC_REC_COUNT>123.45</CP_SUCC_REC_COUNT>
        <CP_ERR_REC_COUNT>123.45</CP_ERR_REC_COUNT>
        <VMS_SUCC_REC_COUNT>123.45</VMS_SUCC_REC_COUNT>
        <VMS_ERR_REC_COUNT>123.45</VMS_ERR_REC_COUNT>
        <SOURCE_TYPE>str1234</SOURCE_TYPE>
        <RUN_ID>123.45</RUN_ID>
        <RUN_SEQ>123.45</RUN_SEQ>
        <RUN_DATE>2012-12-13</RUN_DATE>
      </RPT_ROW>
    </MM_RECON_REPORT>
    example XSD file :
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:annotation>
        <xsd:documentation xml:lang="en">
        XML Schema generated by Data Services
        </xsd:documentation>
      </xsd:annotation>
    <xsd:simpleType name="DIType-decimal-28-0">
      <xsd:restriction base="xsd:decimal">
        <xsd:totalDigits value="28"/>
        <xsd:fractionDigits value="0"/>
      </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="DIType-varchar-200">
      <xsd:restriction base="xsd:string">
      <xsd:maxLength value="200"/>
      </xsd:restriction>
      </xsd:simpleType>
    <xsd:simpleType name="DIType-varchar-10">
      <xsd:restriction base="xsd:string">
        <xsd:maxLength value="10"/>
      </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="DATE">
      <xsd:restriction base="xsd:date">
      </xsd:restriction>
      </xsd:simpleType>
    <xsd:element name="MM_RECON_REPORT" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="RPT_DATE" minOccurs="0" maxOccurs="1"/>
            <xsd:element ref="RPT_ROW"  minOccurs="0" maxOccurs="unbounded"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    <xsd:element name="RPT_DATE" type = "DIType-varchar-200"/>
    <xsd:element name="RPT_ROW" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element ref="SRC_EXT_REC_COUNT" />
            <xsd:element ref="PRE_TRANS_REC_COUNT" />
            <xsd:element ref="POST_TRANS_REC_COUNT" />
            <xsd:element ref="PASS_BAPI_REC_COUNT" />
            <xsd:element ref="TOT_SAP_RETURN" />
            <xsd:element ref="TOT_SAP_SUCC_REC_COUNT" />
            <xsd:element ref="PARTIAL_SUCC_REC_COUNT" />
            <xsd:element ref="TOT_SAP_ERR_REC_COUNT" />
            <xsd:element ref="MM_SUCC_REC_COUNT" />
            <xsd:element ref="MM_ERR_REC_COUNT" />
            <xsd:element ref="CLS_SUCC_REC_COUNT" />
            <xsd:element ref="CLS_ERR_REC_COUNT" />
            <xsd:element ref="CP_SUCC_REC_COUNT" />
            <xsd:element ref="CP_ERR_REC_COUNT" />
            <xsd:element ref="VMS_SUCC_REC_COUNT" />
            <xsd:element ref="VMS_ERR_REC_COUNT" />
            <xsd:element ref="SOURCE_TYPE" />
            <xsd:element ref="RUN_ID" />
            <xsd:element ref="RUN_SEQ" />
            <xsd:element ref="RUN_DATE" />
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    <xsd:element name="SRC_EXT_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="PRE_TRANS_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="POST_TRANS_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="PASS_BAPI_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="TOT_SAP_RETURN" type = "DIType-decimal-28-0"/>
    <xsd:element name="TOT_SAP_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="PARTIAL_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="TOT_SAP_ERR_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="MM_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="MM_ERR_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="CLS_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="CLS_ERR_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="CP_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="CP_ERR_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="VMS_SUCC_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="VMS_ERR_REC_COUNT" type = "DIType-decimal-28-0"/>
    <xsd:element name="SOURCE_TYPE" type = "DIType-varchar-10"/>
    <xsd:element name="RUN_ID" type = "DIType-decimal-28-0"/>
    <xsd:element name="RUN_SEQ" type = "DIType-decimal-28-0"/>
    <xsd:element name="RUN_DATE" type = "xsd:date"/>
    </xsd:schema>
    compare the xml vs xsd for better understanding

  • How to use external library(in .jar format) in netbeans project?

    How to use external library(in .jar format) in netbeans project?
    Thanks!

    How to use external library(in .jar format) in netbeans project?
    Thanks!

  • How to use Database views in XI

    Hi Folks,
    Any idea about how to use Database views for sending and receiving messages in XI ?
    Regards,

    Farooq,
    My doubt is do i have work in the same fashion as if i am working on a Database Table...?
    For Ex :
    Creating Source and Target Data structure for JDBC adapter in the same format....etc
    Regards.

  • How to use batch files to send the load from ODC to UCM?

    Hello all.
    We're trying to do this along this week and, until now, we couldn't figure out how to use batch files containing metada on ODC and commit the output files to UCM.
    So these are our specs:
    VM 1
    ODC - 10gR3
    OS - Windows XP 32 bits SP3
    DB - Oracle DB 11.2
    VM 2
    No ODC
    UCM 11.1.1.6
    OS - Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)
    We've opened a ticket with Oracle Support to know how we should do this. The number is SR 3-6108348211.
    Let me try to explain what we want to do:
    1 - we have a batch file with all metadata of many files from UCM
    2 - we want to use this file in ODC, so the application will convert the images and commit them to UCM
    3 - we should see all these files, their metadata, thumbnails and related content in UCM
    4 - this is a batch file example we want to send to ODC:
    @Properties LocalData
    IdcService=CHECKIN_UNIVERSAL
    dRevLabel = 1
    primaryFile=/tra/Relatorio_UHPF-03-04-2008-M-RL-EA.pdf
    dDocName=TRA_33
    dDocTitle=UHPF-03-04-2008-M-RL-EA
    dSecurityGroup=MAM_TRA
    dDocType=Document
    dDocAuthor=luis.neotropical
    dInDate=14/05/08
    xC_CLASSIFICACAO=EA - Educação Ambiental
    xC_DATA=01/04/08
    xC_DATAVALIDADE=30/04/08
    xC_LOCALIZACAOFISICA=N/D
    xC_USUARIO_DEP=LUIS FERNANDO DA CAMARA
    xC_TIPO=RL - Relatório
    xC_USINA=UHPF - USINA HIDRELÉTRICA PASSO FUNDO
    xC_FICHA=MAM - Relatorios Ambientais
    xC_IDDOCMAN=TRADocID=157
    xC_IDANEXODOCMAN=TRAFileID=33
    xC_DESTINOINICIAL=Tractebel
    xC_ORIGEM=Neotropical
    xC_FORMATODOCUMENTO=Digital
    xC_GENERODOCUMENTO=
    xC_DOCPRINCIPAL=Sim
    @end
    <<EOD>>
    5 - So, when we use this batch file on ODC, the file (or image) will be converted, all metadata attached and then sent to UCM.
    But we don't know how to do the link between ODC and UCM. The Oracle Support says it is necessary to do some customization. In the books I could not find any info about how to do, just generic information or how to use ODC.
    Is there a way (without customization) to do that? Can anyone give us a step-by-step guide?
    Thanks for all help and guidance.
    Fernando

    What is the one-sentence requirement or issue you're trying to solve?
    If you only want content to be converted to pdf, then you should already have that with your items checked into UCM (if you have IBR enabled).
    if you really want to feed content into ODC using a batchfile, my first thought would be to create a transformation utility/app that will convert your batchfiles to the expected ODC import server folder job format. then you'll have to move or map the content to match.
    Again, without knowing the exact issue/business requirement you're trying to work through, I'd say a redesign of your ingestion process may be in order.
    If you feed content directly into ODC through any supported ODC method (watch folder, email, scanner, fax, etc), then you'll be able to use everything ootb as you'll be able to auto-commit directly into UCM or add an indexing step and manual commit to UCM.
    ODC is basically a front end for indexing and extra ingestion options to your content repo.
    IPM is basically the same, but it includes some extra process-related details (process metadata, process integrations/bpel/bpm, other system integrations/ebs/crm, etc). I don't feel that IPM would help with the transformation-specific question you've put out there.
    -ryan

  • How to Use PHP Files and .tpl files

    I have taken a course and it includes a resource section with templates that I can use. These templates are squeeze page ones and inside the folder are index.php, config.php and a whole lot of .tpl files that open up in empty Stickies on my Mac.
    Can someone explain how to use these files. When I open them in Dreamweaver I see code related to the php files but I can't browse the index.php file in a browser to see what the so called sqeeze page looks like.
    Yikes I'm really lost here.
    thanks
    John

    ORA-06401, 00000, "NETCMN: invalid driver designator"
    Cause: The login (connect) string contains an invalid driver designator.
    Action: Correct the string and re-submit.
    The //ip:port/sid connect string will only work with 10g clients.
    Check your tnsnames.ora file. Does the file have control characters or missing carriage-return characters ? (Maybe you ftp'd the file from a unix box ?)
    I would suggest that you create a new tnsnames.ora - hand edit it (don't copy the old one). If you have sqlplus client - try using it to connect to the remote DB first.
    The instructions for connection to a local or remote DB are all the same (when using plain OCILogon) because the connection is made over TCP.

  • How to use usb files on ipad mini

    how to use usb files on ipad mini

    If you're trying to read files off a USB drive onto an iPad, it really doesn't work. The iPad can read specifically named photo and video files off SOME USB drives, but cannot read documents or music or other kinds of files. And there is zero support to write info from the ipad onto any USB device

Maybe you are looking for

  • How can I print Calendar week from iPad?

    How can I print Calendar week from iPad?

  • Cfprocparam type="OUT" brings back empty value

    ISSUE OBJECTIVE: After conversion from CF 5 to CFMX 7, <cfprocparam type="OUT" brings back empty value OUR STORED PROC: <cfstoredproc procedure="sp_rass_user_guidance" datasource="#rass_data_source#" returncode="YES"> <cfprocparam type="IN" dbvarname

  • Opening a file dialog box with a button while the data graph is running continuos aquisition

    I am running a continuous aquisition that is hardware timed. I display the data on a graph. While running the VI that is displaying the graph I want to open a file to write the data for a period of time then be able to select a new file after the fil

  • Unusual error message

    I've gone to open my project this morning and have been hit with this message. Not sure if this will help: I shot a bunch of clips using the canon 5D mark II. I then needed to add slow-mo to some of them so I purchased and used the Twixtor plugin. Af

  • Need help creating a specific report

    I am trying to create a specific report but to-date can not get it to work the way I want it to. I am trying to create a report that does the following: - lists all my groups I have - if the group has not registered a meeting in a specific week then