Database location in Applet

Hi guys
I'm not an expert in java, so sorry if i'm doing a simple question ;)
I have a java applet that use the postgres jar file to connect to a database, my question is: how can the applet know the database location? if it was a static location would be embuted inside code, but could be any address and authentication...
I hope that information is enougth...
Thanks,
Paulo

Paulo,
In order to access a database from an applet you usually need to make the applet a signed applet and you need to download the JDBC driver together with the applet.
There is plenty of information on the Internet about how to make signed applets and how to download JAR archives together with your applet.
Alternatively, you could use JSP (Java ServerPages) and/or servlets.
The JSTL (JSP standard taglib library) has a set of "SQL" tags specifically for allowing a JSP to interact with a database.
Somewhere, some piece of software needs to know the connection details for the database. There are several ways to do this. If you use a servlet, then the servlet needs to know. Or you could use a properties file downloaded with your applet, or you could do it the most popular way and use PHP (instead of java ;-), or an application server.
Good Luck,
Avi.
Message was edited by:
abramia

Similar Messages

  • DW Procedures to connect to MS ACCESS database located on remote server

    I am confused about the procedures within Dreamweaver CS3 to connect to a MS ACCESS database on a remoter server.
    I am working through a tutorial book, "Dreamweaver 8 with ASP, Cold Fusion and PHP Training from the Source", but the instructions are unclear concerning the procedures to connect to a MS ACCESS database located on a remote server. 
    The book indicates that the server administration has to create the DSN for you and screen shots indicate that you will result in a list of DSNs to choose from when creating the connections .asp file.
    I went through the procedures to create a connections .asp and resulting in a connection without and tables (of course) because I do not initially have any connection information from my remote site.
    I have generated the required two lines of code as follows for my MS ACCESS database connection on my remote server:
    'Database connection info and provider
    strCon="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&_
    Server.MapPath("database\trans.mdb") & ";" &_
    "User ID=xxx;Password=xxxxx"
    The question that I have is:
    How does this connection coding relate to the "connections/conn_newland.asp" file that was create within the Dreamweaver screens?  How do I merge the ASP coding?  The file (/connections/conn_newland.asp) generated within Dreamweaver is as follows:
    <%
    'FileName="Connection_odbc_conn_dsn.htm"
    'Type="ADO"
    'DesignationType="ADO"
    'HTTP="true"
    'Catelog=" "
    'Schema
    Dim MM_conn_newland_STRING
    MM_conn_newland_STRINT = "dsn=newland;"
    %>
    Any advice would be appreciated.  I know that this is simple but debugging an error from an  ASP coding merge would be a "bear" to debug!

    I have not used MS Access myself (fortunately) but I believe it works much like the old, old way of achieving a multi-user database in FileMaker.
    That is, it is not a true client-server database but more a peer-to-peer database and that each peer opens the same database file which is available to multiple user via file sharing. Therefore as elikness said it should just be a matter of putting the files on your Lion Server and then sharing that folder/volume using SMB sharing.
    However one thing to be aware of, since MS Access is not a true client-server database I would imagine it uses record locking to manage simultaneous direct access to records in the same files. File or Record locking is something that has historically been a bit flakey when using Windows clients with a Mac file server (and probably vice versa).
    While I am not proposing it as a solution to consider seriously, it is worth you knowing that FileMaker Pro is a database system that is available for both Mac and Windows and depending on how you configure things can be considered to stretch from a configuration very similar to MS Access at the low end all the way to a high-end MS SQL Server style setup at the top end. See http://www.filemaker.com for details.
    There is also a a third-party tool available for migrating databases to or from FileMaker Pro and it can convert MS Access databases to FileMaker Pro see http://www.fmpromigrator.com/
    You could use FileMaker Pro just on Windows machines if you wish.

  • Issue with changing database location at runtime

    I am having a similar issue to:
    Re: Issue with changing database location at runtime
    where I am using Crystal Reports 2008 SP 3 fix pack 3.3 and a OLE DB connection to a SQL 2008 R2 server. Running on a computer on the network where the report can see the original development server is fast, other computers where that server is not available are hanging 20 seconds before coming up.
    I am using the same code from the Crystal Sample app to change the connection on each table. I found that the slowness comes the first time the ReportDocument object is accessed to get the collection of database tables, before the connection info is set.
    Fix pack 3.4 was mentioned in that post.  Does fix pack 3.4 fix that issue? I don't see fix pack 3.4 on the downloads page (https://websmp130.sap-ag.de/sap%28bD1lbiZjPTAwMQ==%29/bc/bsp/spn/bobj_download/main.htm)

    I just found on the reports that were having the issue there was a SQL Expression.  Per this thread:
    Re: Report load is slow after changing database servers
    There was an issue with that and the fix is not out til the end of Feb so I found a way not to use the SQL Expression and the speed is much better.
    However, your information provided led me to this post:
    Cannot Change Table Location, but Only for One Report
    And I am also experiencing an issue where the table location is not changing on one subreport and I will look into that as a possible solution.
    Thanks so much for your help.

  • Changing database location per Table at runtime is extremely slow in viewer

    We are using the Crystal Reports 2008sp2 Viewer in windows forms .NET
    application to display various reports based on a Pervasive database.  The
    C# code dynamically changes the database table locations at run time.  The
    location needs to be set for each table since the location may be different
    for each table in the report. 
    We have tried to methods to change the location.
    1) Set  the Table.Location property in the ReportDocument.Database.Tables
    collection.
    foreach (Table table in rd.Database.Tables)
    Table.Location = "New Path";
    2) Set the TableLogOnInfo properties.
          TableLogOnInfo logonInfo = new TableLogOnInfo();
          logonInfo = table.LogOnInfo;
          logonInfo.ConnectionInfo.ServerName = dataPath;
          logonInfo.ConnectionInfo.LogonProperties[0] = new NameValuePair2("Data
    File", dataPath);
          logonInfo.ConnectionInfo.LogonProperties[0] = new NameValuePair2("Data
    File Search Path", path);
          table.ApplyLogOnInfo(logonInfo);
    Both of these methods work, but have extremely slow performance.  Both
    methods take between 2 and 3 seconds to execute per table.  Since many of
    our reports have 20 - 30 table references ( sometimes more ), this can add
    an additional 1-2 minutes to the display of a report.
    It seems that the Crystal viewer object is doing some sort of verification
    every time the database location is changed.  We have noted that as the
    location is changed, the database is being accessed by the viewer.  Please
    advise as to how to stop this behavior.  Is there a way to set the location
    without the viewer verifying the change?
    This problem is turning reports that run in the 2008 Report Designer in 3 seconds into reports that take
    many minutes to run.  We will hear nothing but screaming from our 300 customers.
    Thanks for any help.
    Bill Smith

    Hello,
    I have a very similar issue but with Crystal XI and XI R2.
    I'm using Oracle 10g, and changing a couple of properties using the following sequence for each table to change the login information and the table's current view (each view is a portion of the overall table):
    IDatabaseTablePtr table = tables->GetItem(tableN);          
    table->SetLogOnInfo(TheApp.GetDataSource(), TheApp.GetDatabase(), userID, pwd);
    char tableLocation[201];
    char tempTable[201], newTable[201];
    strcpy(tableLocation, table->GetLocation());
    // make new table name, put into newTable
    table->PutLocation(newTable);
    if (!table->TestConnectivity())
      ShowCrystalRE_Error(job);
    Stepping through in my debugger, the SetLogOnInfo seems very quick, it's the PutLocation( ) that seems to be taking alot of time.
    Any help would be greatly appreciated.
    This is extremely fast on SQL Server, only noticeably slow on Oracle.

  • WHY can't I access my database from an applet???????????

    The security code won't let my applet access its own database (from its own server)..
    I'm using getDocumentBase()
    to try and tell it that it is my own damn file..
    I keep getting :
    java.securityAccessControlException: access denied <java.util.PropertyPermission jdbc.drivers write>
    ...etc.
    This applet crap is really starting to piss me off. I can see why they came out with JSP.
    All I need to do is access my database, update it, etc. It kind of defeats the purpose of being able to do jdbc from applets if you can't even access the database on your own damn server.
    If you all don't have a clue, I'm freakin switching to PHP--I'm tired of this crap-I was thinking Java was a damn good language until I hit applets.

    The simple answer to your question is: Because of security concerns.
    The somewhat longer answer is that directly accessing a database from an applet is generally not a good idea. A lot of security-critical code like DB username/password must be hidden in the applet which potentially can be downloaded (and disassembled) by anyone that hits your webpage. Maybe you do an intranet solution with trusted users but that is not what applets were originally designed for.
    The clean way is to make your applet talk to a servlet that talks to your database.
    If that is not the way you want to do it, make sure that all client policy files (yes, on the browser machine) contain the permissions that your applet needs.

  • How to set database location for stored procedure

    Post Author: Pavel
    CA Forum: Data Connectivity and SQL
    I've already found out that setting location is not only my problem, but I can't understand the correct decision. We using CR to create reports, accessing the data in MSSQL by ODBC.
    Previously (up to version 8) I set location directly, editing the "Table" field in "Set Location" form. Command after report creation was:
    Proc(DBNAME.dbo.PROCEDURE_NAME;1)
    I erased "DBNAME.dbo.", so the correct command was
    Proc(PROCEDURE_NAME;1)
    After that, the report can run on any database name, any ODBC datasource with any owner name of procedure.
    Now we had to upgdate to CR 11 Developer Edition.
    Here I can't erase database location. But when I change database location to ODBC datasource for another database, the properties of stored procedure "Catalog" and "Owner" remain the same as they initiated when report was created! So, when report runs, it call
    exec OLD_DB_NAME.dbo.PROCEURE_NAME;1 ....
    So, the report doesn't work on customer database, because it has different name.
    How can I erase any database location in the report?We run reports using API from Gupta Team Developer applications, may be it is possible to set database location by API before running report?
    Plese help, any tips are usefull.

    Post Author: Pavel
    CA Forum: Data Connectivity and SQL
    When I set location to another database (i.e. another ODBC datasource) by clicking Update button, "Catalog" property is not changing! It remains unaltered. I had to remove procedure from report and then add procedure from another database, so there was a lot of formatting fileds after that.
    This is not a right decision. I didn't solved current problem, I only temporary patched it.
    The correct desision is to set location programmatically from application.But function PEGetNthTableLocation returns empty strings in CR11, or I incorectly declared this function (from CR8.5):
    BOOL CRPE_API PEGetNthTableLocation ( short printJob,  //handle to print job short tableN,  //number of table struct PETableLocation FAR *location     //structure pointer);typedef struct PETableLocation {    WORD StructSize;    char Location &#91;PE_TABLE_LOCATION_LEN&#93;; //256    char SubLocation&#91;PE_TABLE_LOCATION_LEN&#93;; //256    char ConnectBuffer&#91;PE_CONNECTION_BUFFER_LEN&#93;; //512} PETableLocation;

  • Standby Database Location not listed

    We have the primary database created and the primary database, server, and agent and the standby server and agent are listed in grid control targets. but when I go to create a new standby database, the standby server is not listed for selection in the list of servers to select for Standby Database Location.
    The agent on the server appears to be running and uploading fine.
    Windows 2003 server SP2
    Oracle 10.2.0.3 on Primary
    Oracle 10.2.0.2 repository
    Grid Control 10.1.0.4

    We don't have a standby database because the server isn't listed in the list of Standby Database Locations to choose from. We are trying to create the standby database.
    We've tried to Discover the standby server but it seems to already be Discovered because it is listed as a target when all targets are displayed (target type of host).
    It's almost like the grid control sees the server but for some reason feels it's inelligible to be a standby server.

  • Database Location using Crystal Report XI

    Crystal Report XI Developers Edition; VB 6 Enterprise Edition
    Prior to using Crystal Reports, I will create (if not already there) a database in my Visual Basic project file.
    Via Crystal Report XI, when I designed reports, I used Database Location as my project file where I stored a copy of the .mdb file.
    Prior to creating an "installaltion setup" package, I will create a Directory in Program Files. Let's use and example--I'll call the Directory in Program Files "Sports" so what I do is to copy the ".mdb" file to this directory and change the database location in the rpt files to "C:\Program Files\Sports".
    I have a question, in most install packages, the installer has the option to change the location of the setup files. Let's say installing my application, the user changes the directory. Therefore, the setup files (including the database) are not in "C:\Program Files\Sports" they are in "C:\Program Files\SomeOtherDirectory".
    QUESTION: How does Crystal Report know about this change? Remember in the design I setup the database location as ""C:\Program Files\Sports". Is there a way to tell CR where the database file is located (i.e. application path)?
    Thanks,
    Sam

    The Crystal Reports dlls must be in the correct Bin directory (depends on the version of CR used). You can not change this. If you are using a database such as Access mdb, you can set the report to look in it's own directory for the mdb database. If that is what will work for you, ensure that the report and the database file are in the same folder. let me know if you need more info on this.
    Ludek

  • Not working. Change database location trough VB 6

    Hi,
    I just finished two reports in Crystal 10 using an Access Database (database  location and query are hardcoded in the reports.
    I made a small vb 6 application to launch the reports. Now I need to change database location for the reports trough VB 6.  I have the following code, but it is not working. The reports do not show any data and I do not get any error. I think the problem is with the hardcoded query. The report is designed on this query and the field reference on the reports are like Command.Field1
    I just want tho change database location in VB, but I want the report take the query that is in it.
    I have the following code. How can I make them work.? Is there a better way to do it?
    Dim Report As New CR2 'set up the report
    Dim conn3 As New ADODB.Connection  'ADO connection
    Dim rs As New ADODB.Recordset      'rs connection
    Function F_ViewReport()
    'On Error GoTo End_FormLoad
        Dim sSQL2 As String
        gsRootJob = "4850"
        Dim sSQL2 As String
        gsRootJob = "4850"
    "SELECT Material.Job, Material.Indicator, PO_Detail.Order, Source.Act_Qty,  Vendor.Name, PO_Header.PO, PO_Detail.Due_Date FROM (((Material LEFT JOIN Source ON Material.Material_Req = Source.Material_Req) LEFT JOIN PO_Detail ON Source.PO_Detail = PO_Detail.PO_Detail) LEFT JOIN PO_Header ON PO_Detail.PO = PO_Header.PO) LEFT JOIN Vendor ON PO_Header.Vendor = Vendor.Vendor WHERE (((Material.Job) Like '" & gsRootJob & "*')) ORDER BY Material.Job, PO_Header.PO, PO_Detail.Line;"
        Report.DiscardSavedData
        Set conn3 = New ADODB.Connection
        conn3.Open "provider=Microsoft.jet.OLEDB.4.0; Data Source=" & App.Path & "\Data tables.mdb"
        Set rs = New ADODB.Recordset
        rs.Open sSQL2, conn3, adOpenKeyset, adLockReadOnly
        Report.Database.SetDataSource rs, , 1
        CRViewer2.ReportSource = Report
        CRViewer2.DisplayTabs = False
        CRViewer2.ViewReport
        CRViewer2.Zoom 1
        Screen.MousePointer = vbHourglass
    Please help!
    cc

    Hi Cris,
    It seems that you are having issue with SDK's.
    Post your question in SDK forum.
    [SAP Crystal Reports, version for Visual Studio;
    You can download samples from here:
    [https://www.sdn.sap.com/irj/boc/samples]
    That forum is monitored by qualified technicians and you will get a faster response there. Also, all SDK queries remain in one place and thus can be easily searched in one place.
    Thank you for your understanding,
    Regards,
    Shweta

  • Changing Changing Database Location During Runtime

    I'm using Netbeans 6.0.1. My database location ALWAYS change in place. That's why I'm planning that there would be a "Database Settings..." inside my program. But I don't know how to change the current: user, password, url settings of my program DURING RUNTIME. Here's my persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
      <persistence-unit name="LibraryPU" transaction-type="RESOURCE_LOCAL">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <class>desktopapplication2.Books</class>
        <properties>
          <property name="toplink.jdbc.user" value="root"/>
          <property name="toplink.jdbc.password" value="password"/>
          <property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/Library"/>
          <property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
        </properties>
      </persistence-unit>
    </persistence>

    To solve the "why the hell would I want that stuff inside a jar file" issue, I googled a bit and found this
    style of approach in a Oracle forum. Essentially think of the persistence.xml file as an template
    that the program uses.
    I use a properties file to set all local DB configuration aspects. Load the properties at application
    startup and set then extract the required fields into a Map to create the persistent unit.
    All the "examples" I seen always use a static xml which is never what you need in the real
    world.
    Map properties = new HashMap();
    properties.put(TopLinkProperties.JDBC_URL, dbProps.getString("abc.jdbcurl") );
    properties.put(TopLinkProperties.JDBC_DRIVER, dbProps.getString("abc.jdbcdriver"));
    properties.put(TopLinkProperties.JDBC_USER, dbProps.getString("abc.user"));
    properties.put(TopLinkProperties.JDBC_PASSWORD, dbProps.getString("abc.password"));
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("abcPU", properties);
    entityManager = emf.createEntityManager();
    HTH Altimes.

  • How to get database connection in applet

    Hi,
    I am trying to prepare database connection in applet. After preparing connection with database it'll read same values from table.
    At the time of development it works fine. I have used esclipse IDE for coding and testing.
    But when I try to call that applet from browser. It is giving ClassNotFound exception.
    Does anybody know How to get database connection in applet ?
    Please help me if anybody know solution for this.
    Thanks,
    Rajesh

    As per my knowledge is conserned
    1 u can get the database connection in a jsp page and u send the result set as param to the applet and u can use retrieved values as if they were of the same applet if u r interested i can send the db connetion coding for jsp my id [email protected]

  • How to set database location in the crystal report X1 from the Source code.

    Dear All,
    I am using Crystal report X1 for report generation.Now I am setting the database location manually in the crystal report. How can I Set the database location from the Source code.
    Awaiting for your reply.
    Thanks in advance.
    Regards,
    Rahaneef T

    Here's a routine that also searches for subreports to set the log on info. Simply remove that aprt to set the main report logon info:
    IDatabaseTablePtr pTable;
    //get first table
    pTable = m_Report->Database->Tables->GetItem(1) ;
    long lTableCount = m_Report->Database->Tables->Count;
    for( long lTable=1; lTable<=lTableCount; lTable++ )
         pTable = m_Report->Database->Tables->GetItem(lTable);
         pTable->ConnectionProperties->DeleteAll();
         pTable->ConnectionProperties->Add("DSN", "Name of your DSN");
         pTable->ConnectionProperties->Add("Database", "Demo");
         pTable->ConnectionProperties->Add("Password", "sa");
         pTable->ConnectionProperties->Add("User ID", "1Oem2000");
    // Log on the tables of the subreports.
    long lSectionCount = m_Report->Sections->Count;
    for( long lSection=1; lSection<=lSectionCount; lSection++ )
         ISectionPtr pSection = m_Report->Sections->Item[lSection];
         long lSubreportCount = pSection->ReportObjects->Count;
         for( long lSubreport=1; lSubreport<=lSubreportCount; lSubreport++ )
              IReportObjectPtr pSubreportObject = pSection->ReportObjects->Item[lSubreport];
              CRObjectKind crObjectKind;
              pSubreportObject->get_Kind(&crObjectKind);
              if( crObjectKind == crSubreportObject )
                   ISubreportObjectPtr SubReportPtr = pSubreportObject;
                   IReportPtr pSubReport = SubReportPtr->OpenSubreport();
                   long lTableCount = pSubReport->Database->Tables->Count;
                   for( long lTable=1; lTable<=lTableCount; lTable++ )
                        pTable = m_Report->Database->Tables->GetItem(lTable);
                        pTable->ConnectionProperties->DeleteAll();
                        //pTable->ConnectionProperties->Add("DSN", "dwcb12003");
                        pTable->ConnectionProperties->Add("Database", "CrystalEport_DB");
                        pTable->ConnectionProperties->Add("Password", "sa");
                        pTable->ConnectionProperties->Add("User ID", "1Oem2000");
    If that doesn't work you need to tell us what is the error you are getting and paste in the code you are using.

  • What is the default database location of os x server 10.6.8

    A guy at work just mistakenly change the database location of our OS X 10.6.8 server via Server Admin Tools. Now the Wordpress website that is hosted on this machine stops working because MySQL is messed up. I need to change the settings back to the previous default database location before tracing all the mistakes and errors.
    Is the database location of Mac OS X 10.6.8 the same as other Linux variants? Is it /var/mysql?
    Would anyone check the settings in Server Admin Tools for me?
    Thanks a bunch in advance.

    Yep, I did use ps command to search for another mysqld deamon process already. Didn't find any other mysqld at all...
    The documentation on MySQL's site suggests that this could also be the firewall problem. So I checked /etc/hosts, and 127.0.0.1 localhost is already there.
    sh-3.2# ps -Al | grep -i "mysqld"
       0 41319 41307     4006   0  31  0  2435116    464 -      S+   ffffff8019f66180 ttys001    0:00.00 grep -i mysqld
    Another strange thing is that, from the log file, it seems that the mysqld deamon tries to start up and shut down every few minutes. So, there are repetitive complains in the log files about mysql.sock being not available...

  • Database connection in applet works in Netscape but not in IE

    Hello,
    we have an applet which connects through an jdbc:odbc connection to an Access database.
    When we run it in Netscape 4.7, the applet connects to the database and finds records. When we run it in IE (5.5), we get an error.
    Haven't completely figured out where, but most likely when we try to get the connection:
    con = DriverManager.getConnection(url, "loginname", "password");
    We end up in the catch block.
    Any suggestions what the problem could be?
    TIA
    Gunter

    Can u send me code and let me see.
    Tell me all specification which Access driver you are using and which DSN you are using.
    Let me know i know i can help u out.

  • Need help connecting to a database with an applet

    I am making a Java game that runs in an applet and needs to connect to a Java DB database. I created the database and table in NetBeans and now I have no idea how to connect this applet to the database. I tried using a DataSource and an InitialContext and I got a NoInitialContextException. Any help would be appreciated thanks.

    Already made the InitialContext. This is the code I used in the applet:
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup("jdbc:derby://localhost:1527/GameDatabase");
    Connection con = ds.getConnection();
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM Scenery");

Maybe you are looking for

  • How do I clear environment variables in 10.6

    I am having some difficulty in configuring custom paths with my environment variable, environment.plist.  In setting up some of my software, I am trying to configure custom paths so that I can eventually store preferences on the server for all users

  • Copy from clipboard button in Select Options variable

    Has anyone had success using the copy from clipboard button in the Selection Option variable when copying rows from your query results in Excel?0 My users and I can not get this to work. Is there a setting or something that we are missing? Thanks for

  • How to use acquired values for different treatments with NI 9188 cDAQ

    hi guys, I am trying to use NI DAQ 9188 chasis with 9214 temperature measurement module. I wired 3 modules to the module and split signals. But I am not sure that I can these values into functions vis easily. I am trying to convert them into 1D array

  • Z77a-G43 with I7 2600K no Video

    I have been pulling my hair out, I recently purchased a new Z77a-g43 mother board and an I7 2600K processor. Everything posts fine and I installed win7 64bit and installed the drivers, but when it reboots it starts loading windows and then just shuts

  • False international billing

    I switched to Fios for my phone and internet last week. Prior to the appointment to install I called verizon billing and confirmed that international long distance service will not be part of this bundle or else they would not need to change it. The