PLS help me about file access!!

now the file struct is like the bellow:
<root>/db
db.db
<root>/server
RemoteDataImp.java
how to write the code in RemoteDataImp.java to access file db.db??
the code writen bellow is wrong!
dataWrapper = new Data("../db/db.db");

first if this is a file for your database then you need to connected to
the machine and then you make the code that can access this file
if you use windows then all you have to do is go to control panel
and then open Data Sources (ODBC)in User DSN click on Add button
there choose the database driver if you use Access then double click on
that then anther box will popup there in Data Source Name write the name
of the file or any name let say in your case the name is db.db
then down there you will see a button calls Select click on that
button to select the file you have saved you database in
I will give you an idea about how to call you database files if you use Access
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class RemoteDataImp {
  private static final String DEFAULT_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
  private static final String DEFUALT_CONNECTION_INFO = "jdbc:odbc:db.db";
  private PreparedStatement setUserNames,removeUserNames;
  private static Connection connection;
  public RemoteDataImp(String driver,String info)throws Exception{
    if (driver == null) driver = DEFAULT_DRIVER;
    if (info == null) info = DEFUALT_CONNECTION_INFO;
    Class.forName(driver).newInstance();
    connection = DriverManager.getConnection(info);
    connection.setAutoCommit(true);
  public PreparedStatement prepareConnection(String sql) throws Exception{
    return connection.prepareStatement(sql);
  public RemoteDataImp()throws Exception {
    this(DEFAULT_DRIVER,DEFUALT_CONNECTION_INFO);
  public void saveToDB(/*the user calss which is containing the set and get */ user) throws Exception{
    RemoteDataImp r = new RemoteDataImp();
    if (setUserNames == null) {
       setUserNames = r.prepareConnection("INSERT INTO userTable (USER_ID,NAME,E_MAIL) VALUES(?,?,?)");
     setUserNames.setString(1,user.getUserId());
     setUserNames.setString(2,user.getName());
     setUserNames.setString(3,user.getEmail());
      setUserNames.execute();
  ublic void removeFromDB(/*the user calss which is containing the set and get */ user) throws Exception {
    DatabaseConnection d = new DatabaseConnection()
    if (removeUserNames == null) {
   removeUserNames = d.prepareConnection("DELETE FROM userTable WHERE USER_ID =?");
removeUserNames.setString(1,user.getUserId());
    removeUserNames.execute();
  public void finalize() throws Throwable {
    try {
      connection.close();
    catch (Exception ex) {
}

Similar Messages

  • Pls help me: about log in

    Dear all,
    I have a created a dynamic page (PHP and mysql) with log in
    (server vehaviour) page. and after user had enter their username
    and password, if succeed they go to new page. in this new page ,
    they can submit news. and my big problem is (sorry iam new bie) how
    i can get their username in this new page that they had entered in
    log in page, i want to search id_user in tabel1( field: id_user,
    username, password) with their username and after got it , i want
    to insert this id_user into table2 (filed: id_user, no_news,
    date_news, news ). I hope my explaination will be understood. tks 4
    any help....

    I don't need the code, you do. :O) Read the instructions
    below. Replace
    the parts of the code that are bad with parts of the code
    thar are good.
    Let's look at the tutorial/post, posted below in it's
    entirety from
    http://friendsofed.infopop.net/2/OpenTopic?a=tpc&s=989094322&f=8033053165&m=324102421&r=32 4102421#324102421.
    1. Log In User needs changes in two places, plus the removal
    of three
    lines. Find the following lines of code
    $GLOBALS['PrevUrl'] = $accesscheck;
    session_register('PrevUrl');Replace them with
    $_SESSION['PrevUrl'] = $accesscheck;2. Then find
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;Change them to
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;
    3. Finally, DELETE the following lines
    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");That's it. You're done with
    your Login
    form. You know need to replace a few lines in your logout,
    but we'll wait
    on
    that.===========================Article========================I
    have
    discovered there is a serious bug with the Dreamweaver MX
    2004 User
    Authentication server behaviors when used in conjunction with
    PHP5.
    Basically, the problem is that the DW server behaviors use
    obsolete code
    that appears to work with PHP4, but breaks once deployed on
    PHP5 (with
    register_globals set to the default off setting).
    I have notified Macromedia of the problem, and they have
    logged it as a high
    severity bug, but have given no indication as to when a patch
    will be
    issued. Fortunately, the solution is easily fixed by hand.
    The server
    behaviors affected are Log In User and Log Out User.
    Log In User needs changes in two places, plus the removal of
    three lines.
    Find the following lines of code
    $GLOBALS['PrevUrl'] = $accesscheck;
    session_register('PrevUrl');Replace them with
    $_SESSION['PrevUrl'] = $accesscheck;Then find
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;Change them to
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;Finally, DELETE
    the following
    lines
    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");
    In Log Out User, locate these two lines
    session_unregister('MM_Username');
    session_unregister('MM_UserGroup');Replace them with
    unset($_SESSION['MM_Username']);
    unset($_SESSION['MM_UserGroup']);
    NOTE: There is NO need to do this if you are still using
    PHP4, and not
    experiencing any difficulties with User Authentication.
    However, it does
    affect the instructions for Chapters 14 and 15 of Foundation
    Dreamweaver MX
    2004 for anyone switching to PHP5.
    David Powers
    Co-author: Foundation Dreamweaver MX 2004
    "jangade" <[email protected]> wrote in
    message
    news:[email protected]...
    > Sorry, i still don't understand about that tutorial, can
    u explain me more
    > detail pls ( i am using php triad: php 4, mysql 1.3 and
    apache 1.3 ). i
    > give u
    > the code :
    >
    > login page code:
    > <?php require_once('Connections/koneksi.php'); ?>
    > <?php
    > // *** Validate request to login to this site.
    > session_start();
    >
    > $loginFormAction = $_SERVER['PHP_SELF'];
    > if (isset($accesscheck)) {
    > $GLOBALS['PrevUrl'] = $accesscheck;
    > session_register('PrevUrl');
    > }
    > login page :
    >
    > if (isset($_POST['pemakai'])) {
    > $loginUsername=$_POST['pemakai'];
    > $password=$_POST['sandi'];
    > $MM_fldUserAuthorization = "";
    > $MM_redirectLoginSuccess = "sukses_login.php";
    > $MM_redirectLoginFailed = "tmbhdtteknisi.php";
    > $MM_redirecttoReferrer = false;
    > mysql_select_db($database_koneksi, $koneksi);
    >
    > $LoginRS__query=sprintf("SELECT username, password FROM
    tblteknisi WHERE
    > username='%s' AND password='%s'",
    > get_magic_quotes_gpc() ? $loginUsername :
    addslashes($loginUsername),
    > get_magic_quotes_gpc() ? $password :
    addslashes($password));
    >
    > $LoginRS = mysql_query($LoginRS__query, $koneksi) or
    die(mysql_error());
    > $loginFoundUser = mysql_num_rows($LoginRS);
    > if ($loginFoundUser) {
    > $loginStrGroup = "";
    >
    > //declare two session variables and assign them
    > $GLOBALS['MM_Username'] = $loginUsername;
    > $GLOBALS['MM_UserGroup'] = $loginStrGroup;
    >
    > //register the session variables
    > session_register("MM_Username");
    > session_register("MM_UserGroup");
    >
    > if (isset($_SESSION['PrevUrl']) && false) {
    > $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    > }
    > header("Location: " . $MM_redirectLoginSuccess );
    > }
    > else {
    > header("Location: ". $MM_redirectLoginFailed );
    > }
    > }
    > ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
    4.01//EN"
    > "
    http://www.w3.org/TR/html4/strict.dtd">
    > <html>
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    > <title>Selamat Datang</title>
    > .......
    >
    >
    >
    > and new page :
    > <?php
    > //initialize the session
    > session_start();
    >
    > // ** Logout the current user. **
    > $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    > if ((isset($_SERVER['QUERY_STRING'])) &&
    ($_SERVER['QUERY_STRING'] !=
    > "")){
    > $logoutAction .="&".
    htmlentities($_SERVER['QUERY_STRING']);
    > }
    >
    > if ((isset($_GET['doLogout']))
    &&($_GET['doLogout']=="true")){
    > //to fully log out a visitor we need to clear the
    session varialbles
    > session_unregister('MM_Username');
    > session_unregister('MM_UserGroup');
    >
    > $logoutGoTo = "index.php";
    > if ($logoutGoTo) {
    > header("Location: $logoutGoTo");
    > exit;
    > }
    > }
    > ?>
    > <?php
    > session_start();
    > $MM_authorizedUsers = "";
    > $MM_donotCheckaccess = "true";
    >
    > // *** Restrict Access To Page: Grant or deny access to
    this page
    > function isAuthorized($strUsers, $strGroups, $UserName,
    $UserGroup) {
    > // For security, start by assuming the visitor is NOT
    authorized.
    > $isValid = False;
    >
    > // When a visitor has logged into this site, the Session
    variable
    > MM_Username set equal to their username.
    > // Therefore, we know that a user is NOT logged in if
    that Session
    > variable
    > is blank.
    > if (!empty($UserName)) {
    > // Besides being logged in, you may restrict access to
    only certain
    > users
    > based on an ID established when they login.
    > // Parse the strings into arrays.
    > $arrUsers = Explode(",", $strUsers);
    > $arrGroups = Explode(",", $strGroups);
    > if (in_array($UserName, $arrUsers)) {
    > $isValid = true;
    > }
    > // Or, you may restrict access to only certain users
    based on their
    > username.
    > if (in_array($UserGroup, $arrGroups)) {
    > $isValid = true;
    > }
    > if (($strUsers == "") && true) {
    > $isValid = true;
    > }
    > }
    > return $isValid;
    > }
    >
    > $MM_restrictGoTo = "index.php";
    > if (!((isset($_SESSION['MM_Username'])) &&
    > (isAuthorized("",$MM_authorizedUsers,
    $_SESSION['MM_Username'],
    > $_SESSION['MM_UserGroup'])))) {
    > $MM_qsChar = "?";
    > $MM_referrer = $_SERVER['PHP_SELF'];
    > if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    > if (isset($QUERY_STRING) &&
    strlen($QUERY_STRING) > 0)
    > $MM_referrer .= "?" . $QUERY_STRING;
    > $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar .
    "accesscheck=" .
    > urlencode($MM_referrer);
    > header("Location: ". $MM_restrictGoTo);
    > exit;
    > }
    > ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
    4.01//EN"
    > "
    http://www.w3.org/TR/html4/strict.dtd">
    > <html>
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    > <title>Registrasi</title>
    > <link href="css/stylesnew.css" type="text/css"
    media="screen"
    > rel="stylesheet">
    > <!--[if gte IE 5]>
    > <style>
    > #LeftMNav ul a {height: 1em;}
    > #LeftMNav li {float: left; clear: both; width: 100%;}
    > </style>
    > <![endif]-->
    > <style type="text/
    > ........
    >
    > how i can get username that user entered(login page) in
    new page ?
    > pls help me i'm just new bie....
    > tks 4 kind attentions,
    >
    > regds
    >
    >
    >
    >
    >
    >

  • Pls Help! Failed to access local Session bean in 7.0!

    Hi all,
    Heard that to deploy local bean in weblogic 7.0, I need to put my war
    file and ejb jar files in the ear file. My client servlet contains the
    following:
    AccessControlLocalHome accessControlLocalHome =
    (AccessControlLocalHome)ctx.lookup("AccessControlLocalHome");
    But it failed miserably with the exception
    javax.naming.LinkException: . Root exception is
    javax.naming.NameNotFoundExcept
    ion: Unable to resolve
    'app/ejb/AccessControlBean.jar#AccessControlBean/local-ho
    me' Resolved: 'app/ejb'
    Unresolved:'AccessControlBean.jar#AccessControlBean' ; r
    emaining name 'AccessControlBean.jar#AccessControlBean/local-home'
    Just got an idea that it might be my web.xml file. So I include the
    following in my web.xml file:
    <ejb-local-ref>
         <ejb-ref-name>ejb/AccessControlLocalHome</ejb-ref-name>
         <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocalHome</local-home>
    <local>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocal</local>
    <ejb-link>AccessControlBean.jar#AccessControlBean</ejb-link>
    </ejb-local-ref>
    But it gives the following error:
    Module Name: projects, Error: weblogic.j2ee.DeploymentException: Could
    not setup
    environment - with nested exception:
    [javax.naming.NameNotFoundException: Unable to resolve ejb-link.
    AccessControlBe
    an.jar#AccessControlBean is not in the context. The context includes
    the followi
    ng link bindings: {} Make sure the link reference is relative to the
    URI of the
    referencing module.]
    Pls help!
    Thanks!
    Innovest

    <ejb-link> should be
    <ejb-link> ../AccessControlBean.jar#AccessControlBean</ejb-link>
    innovest wrote:
    Hi all,
    Heard that to deploy local bean in weblogic 7.0, I need to put my war
    file and ejb jar files in the ear file. My client servlet contains the
    following:
    AccessControlLocalHome accessControlLocalHome =
    (AccessControlLocalHome)ctx.lookup("AccessControlLocalHome");
    But it failed miserably with the exception
    javax.naming.LinkException: . Root exception is
    javax.naming.NameNotFoundExcept
    ion: Unable to resolve
    'app/ejb/AccessControlBean.jar#AccessControlBean/local-ho
    me' Resolved: 'app/ejb'
    Unresolved:'AccessControlBean.jar#AccessControlBean' ; r
    emaining name 'AccessControlBean.jar#AccessControlBean/local-home'
    Just got an idea that it might be my web.xml file. So I include the
    following in my web.xml file:
    <ejb-local-ref>
    <ejb-ref-name>ejb/AccessControlLocalHome</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocalHome</local-home>
    <local>com.spear.ejb.simorder.VendorOrderSLBean.AccessControlLocal</local>
    <ejb-link>AccessControlBean.jar#AccessControlBean</ejb-link>
    </ejb-local-ref>
    But it gives the following error:
    Module Name: projects, Error: weblogic.j2ee.DeploymentException: Could
    not setup
    environment - with nested exception:
    [javax.naming.NameNotFoundException: Unable to resolve ejb-link.
    AccessControlBe
    an.jar#AccessControlBean is not in the context. The context includes
    the followi
    ng link bindings: {} Make sure the link reference is relative to the
    URI of the
    referencing module.]
    Pls help!
    Thanks!
    Innovest

  • Pls help me about Runtime.getRuntime().exec("java...")

    I have two applications. One is Client, the other is Platform.
    In the Platform, there are source files packaged into a library named ZtConfig.jar used by Client. If run Client and Platform, two applications can execute normally.
    But if Client is started by user from platform, there is something wrong.
    I noticed the error difficultly with finally catching exception.
    I was puzzled. It is so strange. Pls help me. I list some codes here.
    In Client where finally exception catched:
    import zt.config;
            try {
              xmlFileUrl = new java.net.URL(
                  "file:///e:/Client/src/config/nsr1000.xml");
            catch (IOException ex1) {
              FileLogger.error(ex1.getMessage());
            FileLogger.info("NSR1000Document.setIEDContent", xmlFileUrl.toString());
            try {
              xmlLoader = new XMLConfigLoader(xmlFileUrl);
            finally {
              FileLogger.error("NSR1000Document.setIEDContent",
                               "cannot new XMLConfigLoader object");
              return; // the following codes cannot execute, so have to return here.
    In the XMLConfigLoader, the constructor is
      public XMLConfigLoader(java.net.URL xmlFileUrl) {
        this.xmlFileUrl = xmlFileUrl;
        configDoc = null;
        builder = null;
        xmlDoc = null;
    Platform start Client application using the following code
      Runtime.getRuntime().exec(
                    "java -jar e:/Client/Client.jar");

    I've got it!
    Briefly, it is because classpath setting was overwritten by JBuilder.
    Firstly, I start Platform from JBuilder. In its messages window. The command is
    d:\j2sdk1.4.2_06\bin\javaw -classpath "JBPATH" zt.client.nsr1000.NSR1000App
    Now, classpath environment variable was changed to be JBPATH. While I start
    Client use Runtime.getRuntime().exec("java -jar Client.jar"), it will not run for classpath changed.
    Then, I configured all packages used by Client into JBuilder libraries, including
    Client.jar. And changed codes Runtime.getRuntime().exec("java -jar Client.jar") to be Runtime.getRuntime().exec("java -Xmx128m zt.client.nsr1000.NSR1000App")
    I also changed CLASSPATH windows system environment variable.
    I found this from command console, it can display exceptions. But from JBuilder, there is no exception that can be captured. So debug is difficult.

  • Pls help me about two java virtual machine

    have two applications. One is Client, the other is Platform.
    In the Platform, there are source files packaged into a library named ZtConfig.jar used by Client. If run Client and Platform, two applications can execute normally.
    But if Client is started by user from platform, there is something wrong.
    I noticed the error difficultly with finally catching exception.
    I was puzzled. It is so strange. Pls help me. I list some codes here.
    In Client where finally exception catched:
    import zt.config;
            try {
              xmlFileUrl = new java.net.URL(
                  "file:///e:/Client/src/config/nsr1000.xml");
            catch (IOException ex1) {
              FileLogger.error(ex1.getMessage());
            FileLogger.info("NSR1000Document.setIEDContent", xmlFileUrl.toString());
            try {
              xmlLoader = new XMLConfigLoader(xmlFileUrl);
            finally {
              FileLogger.error("NSR1000Document.setIEDContent",
                               "cannot new XMLConfigLoader object");
              return; // the following codes cannot execute, so have to return here.
            }In the XMLConfigLoader, the constructor is
      public XMLConfigLoader(java.net.URL xmlFileUrl) {
        this.xmlFileUrl = xmlFileUrl;
        configDoc = null;
        builder = null;
        xmlDoc = null;
      }Platform start Client application using the following code
      Runtime.getRuntime().exec(
                    "java -jar e:/Client/Client.jar");

    I've got it!
    Briefly, it is because classpath setting was overwritten by JBuilder.
    Firstly, I start Platform from JBuilder. In its messages window. The command is
    d:\j2sdk1.4.2_06\bin\javaw -classpath "JBPATH" zt.client.nsr1000.NSR1000App
    Now, classpath environment variable was changed to be JBPATH. While I start
    Client use Runtime.getRuntime().exec("java -jar Client.jar"), it will not run for classpath changed.
    Then, I configured all packages used by Client into JBuilder libraries, including
    Client.jar. And changed codes Runtime.getRuntime().exec("java -jar Client.jar") to be Runtime.getRuntime().exec("java -Xmx128m zt.client.nsr1000.NSR1000App")
    I also changed CLASSPATH windows system environment variable.
    I found this from command console, it can display exceptions. But from JBuilder, there is no exception that can be captured. So debug is difficult.

  • Pls help with .CAP file.

    Hi.
    I read a lot about how to write java applet for smart card and after read a lot about how to convert .class file into a .CAP file. But I don't know where to find informatin about what to do further. Pls can you tell or give link to a text which explains how to install .CAP file on a smart card and which tool to use in order to save .CAP file on a smart card.
    Thx

    It depends what installer/deletion manager your card supports. Most likely it is GlobalPlatform. Check out GlobalPlatform 2.1.1 card specification.

  • Please help me about Sun Access Manager . . .

    Hi every body,
    I deploy successful Access Manager 7.1 on domain1 in GlassFish server.
    At address admin console domain1 : http://my.test.domain:4848/
    At adress listening : http://my.test.domain:8080/amserver/
    And then I install Policy Agent 2.2 and deploy agentapp.war succesful on domain2 in GlassFish server.
    At address admin console domain2 : http://my.test.domain:6868/
    At adress listening : http://my.test.domain:6948/agentapp.war.
    And then I deploy agentsample.ear on domain2 in GlashFish server and addess deployment is : http://my.test.domain:6948/agentsample
    And then I login Access Manager that create policy : http://my.test.domain:6948/agentsample/*
    When I browser http://my.test.domain:6948/agentsample on IE it redirect to Access Manager login.
    But I read a attach document, it asked me, created user and asign roles employee, manager, admin.
    I wondered that employee, manager and admin roles are available?
    If it hasnt that roles, How to create it ?
    And How to use LDAP and install Sun Directory server in window xp?
    Then end, Can you tell me, Whats wrong if I configure like above ?
    I hope you help me . . .
    Thank you very much.
    VinhND
    Edited by: javatoall on Jan 17, 2008 9:44 PM

    Hi,
    I added a page to the wiki which adds more detail to the steps to create the sample app policies on the am/fam/opensso server console UI. This includes some screen shots as well.
    This is one good thing about the sample app is that you have to learn to install the opensso server, install the agent, configure the agents properties for the sample app security and also use the opensso server UI to create policies.
    It is a bit of work, but when done you will know how to use a lot of opensso features.
    You do not need a directory server. The sample app readme refers to some directory things that really can be ignored. The wording should be changed.
    Anyhow you can use this wiki page along with the readme to help you set up the policies, the subjects etc that map to the sample app
    http://wikis.sun.com/display/OpenSSO/samplepolicy
    I will try to make a getting started page for new users, though you have done most the steps now, and need to set up sample. But this page might be useful for others who want to get started http://wikis.sun.com/display/OpenSSO/getstarted
    hth,
    Sean

  • WTK 2.5.2 Emulator always asks about file access

    Is there a way to suppress the question that the emulator asks about accessing a file using a Fileconnection? It asks it on EVERY SINGLE ACCESS and seriously interferes with debugging. (On the real device, I can give permission once and be done with it).
    Michael D. Spence
    Mockingbird Data Systems, Inc.

    In (for Windows) C:\Documents and Settings\spence\j2mewtk\2.5.2\appdb:
    - Make a copy of _policy.txt so you can undo this later if you want.
    - Find the domain you midlet runs in (e.g., domain: identified_third_party).
    - Change these two lines:
    blanket(oneshot): read_user_data_access
    blanket(oneshot): write_user_data_access
    to read
    allow: read_user_data_access
    allow: write_user_data_access

  • Help me about file size!

    I have a link of a file. Can you help me to know the size of ift before I download it.

    Hi,
    You can't unless you can query the server about the size.
    /Kaj

  • Pls help - produce xml file with an agreed-upon DTD

    I posted this a few weeks ago:
    I have only installed XSU, and I was hopping to use pl/sql package XMLGEN to generate XML with a given DTD and a sql query.
    I can't find input parameter for DTD. Well it seems logical as both DTD and SQL are for defining the XML output file.
    How can this be done ?
    Thanks.
    /Kwan
    Do I need to process the DTD to generate Java classes ? and then create XML document by a java application ?
    I am in a pl/sql shop and I am not eager to go java because I need to use a DTD.
    comments / help ?
    thanks.
    /Kwan
    I am in a pl/sql shop

    Cross-post: http://forum.java.sun.com/thread.jspa?threadID=784467&messageID=4459240#4459240

  • Help me about file and array

    hi
    I need read a file into an array and write a new file from that array.
    for example I read photo.gif into an array (array[ ]) and I write
    newphoto.gif from that array (array[ ] )

    Your read(cleartext) method may or may not read the whole of the file at one time. The value returned by the read is the number of bytes actually read and may not be all the bytes in the file. So the answer is that you can't reliably use your code though it may work most of the time.
    Did you read my comment about reading the whole of a file into memory at one time? Did you bother to look at the reference I posted?
    Message was edited by:
    sabre150

  • Please, help me with file access in Java Applet.

    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class ImageVi extends Applet {
         URL PicPath1;
         Image Img1;
         public void init()
              try
                   PicPath1 = new URL("http://nurchi.far.ru/pic/s08.jpg");
              } catch (MalformedURLException Excep1) {}
         public void paint(Graphics g) {
              Img1=getImage(PicPath1);
              g.drawImage(Img1, 10, 10, this);
    The error message is:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.net.SocketPermission nurchi.far.ru resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:195)
    at java.security.AccessController.checkPermission(AccessController.java, Compiled Code)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java, Compiled Code)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1019)
    at sun.awt.image.URLImageSource.<init>(URLImageSource.java:48)
    at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:40)
    at sun.misc.Ref.get(Ref.java:53)
    at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:275)
    at sun.applet.AppletViewer.getImage(AppletViewer.java:270)
    at java.applet.Applet.getImage(Applet.java:190)
    at ImageVi.paint(ImageVi.java:24)
    at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:116)
    at java.awt.Component.dispatchEventImpl(Component.java:2452)
    at java.awt.Container.dispatchEventImpl(Container.java:1059)
    at java.awt.Component.dispatchEvent(Component.java:2312)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:301)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.java:120)
    at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java:95)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:90)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

    Applets are not allowed to connect to other server
    than the one they were loaded from. This is probably
    the reason here.You mean that I can use the applet after uploading on my web-site and using "getDocumentBase()" only?
    OK.
    The applet works perfectly if I use that function, but I have another question.
    If I want to use something like:
    Img1=getImage(getDocumentBase(), "s01.jpg");
    it works perfectly.
    If I do the fillowing:
    Img1=getImage(getDocumentBase(), "pic/s01.jpg");
    it also works.
    But is it possible to go a level up?
    Like:
    Img1=getImage(getDocumentBase(), "../pic/s01.jpg");
    That is if an applet is in one folder and the pictures are in another, but to get to them I have to go a level up and then enter another folder.
    Please help.
    Thanks.

  • Pls. help me out..Accessing ejb through jsp

    hi all,
    I am running my ejb on the j2sdkee.1.2.1 and jdk1.3 on Windows 2000. I am facing a problem while accessing the ejb from the jsp page. Its running fine when accessing through a client application. The following is the error when I try to access it using:
    http://localhost:8000/first/FirstEJB.jsp
    Error: 500
    Internal Servlet Error:
    org.apache.jasper.JasperException: Unable to compile class for JSP
         at org.apache.jasper.runtime.JspLoader.loadJSP(JspLoader.java:287)
         at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:137)
         at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:148)
         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:247)
         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:352)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
         at org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:626)
         at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:534)
         at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
         at org.apache.tomcat.core.Context.handleRequest(Context.java:644)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
         at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:310)
         at java.lang.Thread.run(Thread.java:484)
    Root cause:
    java.lang.NullPointerException
         at java.io.File.(File.java:181)
         at org.apache.jasper.compiler.JspCompiler.computeClassFileData(JspCompiler.java:285)
         at org.apache.jasper.compiler.JspCompiler.getClassName(JspCompiler.java:103)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:105)
         at org.apache.jasper.runtime.JspLoader$2.run(JspLoader.java:273)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.jasper.runtime.JspLoader.loadJSP(JspLoader.java:270)
         at org.apache.jasper.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:137)
         at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:148)
         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:247)
         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:352)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
         at org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:626)
         at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:534)
         at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
         at org.apache.tomcat.core.Context.handleRequest(Context.java:644)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
         at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:310)
         at java.lang.Thread.run(Thread.java:484)
    The name of the jsp file is FirstEJB.jsp
    The name of the ear file is FirstEJB - Stateless Session Bean
    The name of the WAR File is FirstWAR
    I have created a Web Component named first
    Can anyone tell me how to access the ejb using jsp?
    Thanks,
    ajit

    Hello all,
    Sorry for the trouble. I got the mistake..I had not given the context in the deploytool..
    Thanks,
    ajit

  • Pls help ? about snapshot,urgent!

    first i create a database link remote_connect,and test it,it's active;
    then i create a snapshot log on remote master table:table_one, table_one has it's primary key(id), and last i create snapshot in local like this:
    create snapshot local_table_one
    storage(initial 100k next 100k pctincrease 0)
    tablespace snaps
    refresh fast
    as
    select * from table_one@remote_connect;
    but the errors occur:
    ORA-12014: 1m'TABLE_ONE'2;0|:,Vw9X<|WVT<JxLu<~(table 'table_one' not include primary key check condition);
    my question is:
    how can i do for this,i want use primary key not rowid:
    thanks first!

    This problem occurs when you try to create a snapshot with using WITH PRIMARY KEY option, and the Master table either doesn't have primary key or the primary key is disabled.
    If you don't want to use WITH ROWID option, you'll have to check your master table.
    Either create a primary key or enable it if already exists on the Master table.
    Hope this will help
    Faheem

  • Pls help me about oytput types  URGEEEEEEEEEENT

    hi friends,
    i devoloped a Z smartform and attatched in NACE to output type ZUS3 in V3 application
    that above form is modified to standard from.
    but i am getting the output for VF02 tcode it is generating one spool request properly with some hard code missing that i given in SF.
    but the issue is if i attatch the same form to other output type in NACE like YPFI iam getting the correct output.
    i kept break point in my SF both output types picking the same form (mine only)
    what could be the mistake.
    thanks in Advance.
    VENUMADHAV -SATYAM

    hi
    try this
    hi
    try this
    SQL> conn tom
    Enter password:
    Connected.
    SQL> select count(*) from smitemout;
    COUNT(*)
    1326661
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Pr
    oduction
    With the Partitioning, OLAP and Data Mining options
    SQL> conn / as sysdba
    Connected.
    SQL> select DBMS_LOB.substr(sql_text, 4000)
    2 from v$session s, v$sqlarea where address = sql_address and
    3 Hash_value= sql_hash_value and s.sid = 149;
    DBMS_LOB.SUBSTR(SQL_TEXT,4000)
    SELECT COUNT(*) FROM SMITEMOUT
    SQL>
    regards
    Mohammadi52

Maybe you are looking for

  • Portal on Unix cannot mount Windows File server

    Hi Experts, We had installed a NW 7.0 portal onto HP-UNIX server and integrated it with MS AD server. Now, we are facing an issue that we cannot mount windows files server when we tried to configured it with TREX. Had anyone tried this function or it

  • From as portlet.....It's Urgent!!!!!!!!!!!!!!!!!!!!!!

    Hi I have a form developed in JDeveloper using JClient Object. I want to put this form on my portal page as a portlet. Is it possible to do. Can anyone please help me.It's Urgent. Thanks Ash

  • Validate xml with complextype schema without root element!

    Hi All! I have a problem that. I want to validate a xml data of complextype but the schema i want to validate is[b] not have root element. For example: The schema like that <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="www.thachp

  • Need help: unique constraint

    Hey please tell How to add unique constraint on two columns on a table say Name and id Name should be case independent unique something like alter table xyz. add unique constraint on (upper(name),id ) Thnx

  • VXI-850pc controller fails boot. Drive not ready, light on continuous​ly.

    I have a VXI-850pc slot-0 controller that won't boot properly.  Basically, when turned on:    1) the drive light is continuously lit, color - amber.    2) screen displays: Drive not ready, insert BOOT diskette in A:, Press any key when ready Has the