Connecting to a java db with an application in netbeans 6.7

I'm working through the example found here [http://java.sun.com/docs/books/tutorial/jdbc/basics/] and have successfully created and connected to a database in the services tab. The driver is org.apache.derby.jdbc.ClientDriver and the url is jdbc:derby://localhost:1527/COFFEEBREAK. I have two tables setup just like the example and I can view the data in the services tab. I'm having problems connecting to it with an application. I have included the derby.jar file in my library. I'm trying to use the following code to connect but get a "java.sql.SQLException: Database 'COFFEEBREAK' not found" error. Any help would be appreciated, I've been staring at the for 2 days.
        try         {             Class.forName("org.apache.derby.jdbc.EmbeddedDriver");         } catch (ClassNotFoundException ex)         {             System.out.println("Driver not loaded");             Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);         }         try         {             Connection conn = DriverManager.getConnection("jdbc:derby:COFFEEBREAK");         } catch (SQLException ex)         {             Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);         }

Your embedded Derby is not looking for the database in the same place as your Derby server.
If the server is running as a separate process (which it probably is if you started it using the Netbeans menus) and has booted the database, you won't be able to connect using the embedded driver anyway. You will get an error message which is different from the one you got (I will get back to that).
I assume you have already created the database, since you say you have connected to it via Netbeans' services tab using the client driver. In that case, your problem is that you are not able to find the database, i.e. the embedded Derby driver is looking in a different place than where it is.
The embedded Derby driver does not necessarily know the working directory, or the "derby.system.home" of the server which booted the database when you created it. So you either need to tell it where it is, or use the client driver in your application instead.
Look at your Java DB / Derby server properties in your NetBeans installation. The value for "Database location" is what is your "derby.system.home". So, you can set that in your application as well, by setting it as a system property before booting the embedded driver.
Alternatively, you can specify full path to your database in the connection URL. A third alternative is to move the database to the working directory of your application, but then you need to adjust client URLs if you also want to connect using the client driver....
Going with the first alternative, it will be something like this:
        System.setProperty("derby.system.home", pathFromDatabaseLocationSetting);
        try
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        } catch (ClassNotFoundException ex)
            System.out.println("Driver not loaded");
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        try
            Connection conn = DriverManager.getConnection("jdbc:derby:COFFEEBREAK");
        } catch (SQLException ex)
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }If you get an error saying the database is already booted, you need to either shut down the server (or shut down the database that is booted in the server) first, or use the client driver instead. If you use the client driver, you don't need to set derby.system.home, but you need to have the server running.

Similar Messages

  • Unable to connect SQL server 2005 databse with JSF applications !

    Hello guys!
    Help me out to connect SQL server 2005 Databse with JSF applications using JDBC-ODBC bridge. I'm working with Netbeans 6.1 IDE.
    I tried for the basic applications but instead got this error:
    "unable to deploy jdbc drivers to the <project>domain/lib"
    Please help me out with working sample codes that connects MS SQL server 2005 DB with JSF!!
    Thank you guys!

    1) don't use the bridge driver
    2) don't do database access from JSF
    3) learn how to use your application server
    4) learn how to use your IDE

  • Connecting a Local Java Program with a Mysql Database Hosted on the Interne

    I need help. I want to connect a java program running on local user computers to read and write to a mysql database hosted in my domain by an internet service provider.
    What code do i use?
    How do i connect?

    http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
    You'll ned to downloda the JDBC driver file from MySQL, and check their docs for the format of the connection URL.

  • How to Integrate OIM API with the Application in NetBeans

    Hi All,
    I'm Facing problems to Integrate OIM API with the Application. I'm using Netbeans IDE. Can anyone please let me know the steps to do so?? any documents will also help me.
    Thanks

    Hey,
    Helpful links for you:
    1- http://www.youtube.com/watch?v=Yccl0HqfA3o
    2- http://www.youtube.com/watch?v=ZdMTLRF7P_4
    Let me know if it helps you. I hope so.
    Thiago Leoncio Guimaraes

  • I have a error when i connect to sql exprees 2012 with my application

     hi  
    I have a application , its connected to sql server 2012  express
    user name  :  sa 
    and i have a password 
    in my computer and our company's computer its ok
    now 
    i setup sql server 2012 express in a customer's server 
    i setup my  windows application in server ... its works good (local)
    when i install my app in another network's computer  i see my sql server & i selected my server and create a provider & i tested my connection string its ok
    i have a succesfull connectionstring
    but when i read  records & ... i have a login failed server\ user
    why ?
     attention in customers' server have a sql server 2008 r2 for web
    my database can't restore in 2008 r2
    and any setting its same with my setting

    There can be too many problems that prevent connecting to the database. I suggest you get back with more information when you will have it in order to save us from guessing game :-)
    Don't worry we will be here to help tomorrow too (some of us probably) :-) 
    [Personal Site] [Blog] [Facebook]
    We Iranians do not like insult to others.
    good luck
    Hello Reza,
    I would like you to take answers in lighter way.As far as i can see there was no insult there Pituach just ( with simley) tried to tell you that such a error could be because of many reasons and please can you provide more details.
    SQL server forum includes people from all around world and only thing matters here is knowledge.
    Hope this helps
    Thanks for cooperation
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers
    hello Shanky_621 & RSingh
    &  pituach
    sorry  , You are right 
     i deleted my post 

  • How to use java output with other application

    hi ,
    I am using acme.crypto to encrypt data. this is completely written in java. i need to pass input to this using VB6 and return the output to VB6
    how can i achieve the same, is there any readily available dll that can be used in vb?
    I am rigorously searching solution, which i am not finding.
    I need to know how should i place the java code so that it could be used with VB, as i am new to java world. Do i need to create component using java bean or how?
    The code i refered above is nothing but encryption algorithm. I need to pass the input string from vb to java, which will process me the output which inturn should be passed to vb6.
    Kindly guide me through this.

    Why not create a Java ServerSocket in your Java program.
    Connect the VB program to this ServerSocket.
    Send the input to the Java Program over this socket and have the Java Program encrypt the information and pass it back on the same socket.
    Don't know how hard Sockets are in VB6 but a Server Socket in Java is simple.
    No need for new DLLs, JNI, etc.

  • Java Problems With Some Applications

    Ever since I updated Java Web Start at the end of September I've had problems getting some applications to open correctly. I know that's the problem too because it happened right after I did the update. I updated, restarted the computer, tried to launch an application, and it didn't open up. What happens is the application icon bounces in the dock and then shuts down, almost like it's crashing.
    What's weird though is that it's only the applications...all web-based Java stuff is fine.
    Is there anyway I can roll back to the previous version of Java Web Start?

    If you didn't repair permissions after updating, then I suggest that you do so now. Except this time, do so from your install DVD.
    Repairing permissions from the Tiger or Leopard DVD
    Boot up from your Tiger or Leopard Install DVD while holding down the "c" key.
    Select the language you wish to use, and then choose "Disk Utility" from the menu bar.
    Your HD should appear in a panel on the left hand side of the window which opens. Select it and then click on the "repair disk" button in the right hand section of the window.
    If Disk First aid is able to complete the repair now click on the "Repair permissions" button.
    Once this process has been completed restart your computer.
    See Knowledge Base Article: http://support.apple.com/kb/HT1782 Using Disk Utility in Mac OS X 10.4.3 or later to verify or repair disks
    See Knowlege Base Article:
    http://docs.info.apple.com/article.html?artnum=25751 About Disk Utility's Repair Disk Permissions feature
    TIP-You should Repair Permissions & restart:
    After installing and/or updating an OS (Operating System).
    After installing software.
    After burning sessions

  • Java Problem with Web Application

    Hi Experts
    I have a new poblem of connexion with my tools ( Web A
    In fact when I execute my template, I have this error of communication:
    ERROR JAVA : INCOMING CALL IS NOT AUTORIZED
    I do a lot of thing like :
    Create RFC Destination in J2EE Engine.
    Create RFC Destination for the Portal.
    Maintain Portal Server Settings for the Portal
    Maintain Single Sign-On in the BI System
    Export BI Certificate to the BI System.
    Import BW Certificate to the Portal.
    Create BI System in the Portal.
    Configure User Management in the Portal
    Export Portal Certificate to the Portal
    Importing the Portal Certificate to the J2EE Engine
    Import Portal Certificate to BI System
    Set up Repository Manager for BI Documents and BI Metadata
    Maintain User Assignment in the Portal.
    Import SAP Basis Plug-In to BI System.
    Thanks

    Let's take this one step at a time.
    1. You have successfully configured ABAP/Java communication using template installer? See note 917590.
    2. Did you assign the portal user appropriate portal roles?
    3. Can you start a web query from 7.0 query designer?

  • Connectivity of Oracle 9i DB With ASP Application

    Dear friends,
    Can Any one please help me in solving my problem as follows. I run Oracle 9i Release 2 Database on Red HAt Linux Advanced Server. I also run a web server running on windows 2000 server and IIS 5.0. Now my problem is that whenever i try to coonnect the databse using ASP Pasges it returns me error of the following nature :
    1) objconn.Open "Provider=MSDASQL;Driver={Microsoft ODBC For Oracle};UID = kms;PWD=kms;Server=KMS;"
    Error Message :
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed
    /ORACLE77.ASP, line 8
    2)objconn.Open "Provider=MSDAORA.1;User Id = kms;Password=kms;Data source=KMS;Persist Security Info=False"
    Error Message:
    Microsoft OLE DB Provider for Oracle error '80004005'
    Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.
    3) objconn.Open "DSN=KMS;uid=kms;pwd=kms"
    Error Message :
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    Specified driver could not be loaded due to system error 5 (Oracle in OraHome92).
    My service name is KMS,database name & sid name also is KMS
    PLease Help me out of this problem.

    You may probably look at the possibility of using Oracle Provider for OLEDB.
    You can refer samples on this at following url
    http://otn.oracle.com/sample_code/tech/windows/ole_db/content.html
    This url also gives links for downloading the software.
    Chandar

  • Connecting to desktop Java application from R/3

    I want to connect to a java application program in my desktop and return a parameter to R/3. I have installed Java connector and I want to call the java application from R/3 using Java connector.
    I was able to get few samples to setup the RFC destination for a remote server program, but I was not able to find anything for an application in the client system. How to setup the RFC destination for a Java connector to call the application in the desktop? Can anyone please answer this question.

    Hi Allam,
    1. Why do you need to connect from backend system to your desktop client? Did I understood it correctly that it's exacly what you want to do?
    2. I guess examples you saw are for JCO or JCA which is a part of SAP J2EE server. Simply speaking the server is waiting for a client request and your desktop application probably not. If you still are sure that server->desktop connection is what you need then you have to emulate the server on your self and then depending on what you need JCO/JCA you have to create a kind of container that will implement listening service.
    I'd like to hear your answer for question one to give you more detailed answer.

  • Upgrading Oracle XML Parser for Java v9.0.4 with Oracle Applications 11i

    Guys, I applied ATG.PF.H.RUP4. In postinstall steps it is mentioned,Upgrading Oracle XML Parser for Java v9.0.4 with Oracle Applications 11i(doc-271148.1)
    which says after applying patch 4038964 do the following--
    AUTOCONFIG ENABLED APPLICATIONS ENVIRONMENT
    If the Oracle E-Business Suite configuration files are maintained using the AutoConfig infrastructure, proceed with the following:
    1. Run the AutoConfig utility.
    2. Go to [JAVA_TOP].
    3. Run the unzip -l appsborg2.zip | grep 9.0.4 command. If there is a file named as .xdkjava_version_9.0.4.0.0_production, which indicates that XML Parser for Java v9.0.4 is installed correctly as part of appsborg2.zip. Otherwise, run ADAdmin to regenerate the appsborg2.zip file.
    4. Restart the application tier server processes such that the new version of Oracle XML Parser for Java will take effect.
    but actually the patch is already applied- 4038964. How do i verify if i need to do these steps or not.
    The xmlparserv2-904.zip file is already there in wrapper.classpath. of jserv.properties, forms.properties. So i think i dont need to do these steps.

    unzip -l appsborg2.zip | grep 9.0.4
    0 04-18-03 20:10 .xdkjava_version_9.0.4.0.0_production
    do i still need to do that step?No, you do not have to since "XML Parser for Java v9.0.4" is already installed as part of appsborg2.zip

  • How can I communicate with other applications from my Java application?

    Hello,
    I need help about how can i communicate with other application(say textpad.exe/wordpad.exe/MS word.exe) from my Java program.
    More precisely, I need to know how i can get the current position of the cursor whether it is in any .txt/.doc files, then I may write some text in my java application and click a button and then my program will append the line(string) in that position of the file which is running under another appliction(Notepade.exe/MSword.exe).
    Please provide me some help.

    I may be wrong (and anyone, please correct me if so), but Java may not be the best tool for something such as this. I envision that you'd have to make some OS calls such as calls to the user32.dll, and while this can be done through the JNI, you'd still have to have a C or C++ program doing the dirty work.

  • Accessing Java Object with out any application servers

    Hi,
    I would be much thankful if any one guide/suggest me how to
    access an java object with out using any application servers.I am
    having an java object which holds dummy data and an mxml file which
    contains some text fields. My plan was to access the java object
    and put the dummy data in the text fields. I am using RemoteObject
    for this. I am not able to proceed further. Please help me.
    Thanks in advance
    Regards
    Karun Kumar

    You can check The Merapi Project it's still in the
    development phase but it'll allow to an AIR app invoke a java class
    and run it as it were inside your app. But that's something you
    can't take into production yet, why don't u wanna use a server
    backend?

  • Could Not Establish Connection to AS Java with Available Profiles

    Hi All,
    I am installing AS Java on SAP Netweaver 7.4 SR2.
    OS: Windows Server 2008r2 and DB: MSSQLSever 2012
    During the installation I got the below error on 28th Phase out of 29th.
    "Deploy Java Components"
    Below is the Error Log as extracted from SAPINST Log File
    [ Error ] Could not establish connection to AS Java on [WIN-9OD90N7C:50204]. Cannot establish connection with any of the available profiles:
    url=WIN-9OD90N7C:50204 protocol=p4 (None); Reason: com.sap.engine.services.rmi_p4.P4IOException: Cannot open connection to host: 192.168.245.130 and port: 50204
    Check if server is started, access point for the protocol is available, and IP/Host name is accessible on network.. Check if the host and port specified are correct and AS Java is up and running.
    [ LOG EXCEPTION ]  :: Could not establish connection to AS Java on [WIN-9OD90N7C:50204]. Cannot establish connection with any of the available profiles:
    url=WIN-9OD90N7C:50204 protocol=p4 (None); Reason: com.sap.engine.services.rmi_p4.P4IOException: Cannot open connection to host: 192.168.245.130 and port: 50204
    Check if server is started, access point for the protocol is available, and IP/Host name is accessible on network.. Check if the host and port specified are correct and AS Java is up and running.
    javax.naming.NamingException: Exception while trying to get InitialContext. [Root exception is com.sap.engine.interfaces.cross.DestinationException: Cannot establish connection with any of the available profiles:
    url=WIN-9OD90N7C:50204 protocol=p4 (None); Reason: com.sap.engine.services.rmi_p4.P4IOException: Cannot open connection to host: 192.168.245.130 and port: 50204
    Check if server is started, access point for the protocol is available, and IP/Host name is accessible on network.]
      at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:386)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
      at javax.naming.InitialContext.init(InitialContext.java:223)
      at javax.naming.InitialContext.<init>(InitialContext.java:197)
      at com.sap.engine.services.dc.api.session.impl.SessionImpl.getContext(SessionImpl.java:215)
      at com.sap.engine.services.dc.api.deploy.impl.DeployProcessorImpl.reconnectDeployer(DeployProcessorImpl.java:1954)
      at com.sap.engine.services.dc.api.deploy.impl.DeployProcessorImpl.waitResultForOfflineDeploy(DeployProcessorImpl.java:1626)
      at com.sap.engine.services.dc.api.deploy.impl.DeployProcessorImpl.deployItems(DeployProcessorImpl.java:903)
      at com.sap.engine.services.dc.api.deploy.impl.DeployProcessorImpl.deploy(DeployProcessorImpl.java:259)
      at com.sap.engine.services.dc.api.cmd.deploy.DeployCommand.performOperation(DeployCommand.java:208)
      at com.sap.engine.services.dc.api.cmd.deploy.DeployCommand.executeCommand(DeployCommand.java:540)
      at com.sap.engine.services.dc.api.cmd.AbstractCommand.execute(AbstractCommand.java:197)
      at com.sap.engine.services.dc.api.cmd.Runner.execute(Runner.java:37)
      at com.sap.engine.services.dc.api.cmd.Runner.main(Runner.java:61)
    Caused by: com.sap.engine.interfaces.cross.DestinationException: Cannot establish connection with any of the available profiles:
    url=WIN-9OD90N7C:50204 protocol=p4 (None); Reason: com.sap.engine.services.rmi_p4.P4IOException: Cannot open connection to host: 192.168.245.130 and port: 50204
    Check if server is started, access point for the protocol is available, and IP/Host name is accessible on network.
      at com.sap.engine.interfaces.cross.Destination.getNextAvailableBroker(Destination.java:64)
      at com.sap.engine.interfaces.cross.Destination.getRemoteBroker(Destination.java:39)
      at com.sap.engine.services.jndi.InitialContextFactoryImpl.getInitialContext(InitialContextFactoryImpl.java:298)
      ... 14 more
    Thanks and Regards
    Anurag

    Hi Anurag
    Could you refer the SAP Notes for your issue
    1571274 - Cannot connect to server using message server ms://
    1925352 - How to check the access points (or ports) being used by a live SAP J2EE server
    BR
    SS

  • Open connections between AS Java and AS ABAP when using JRA

    Hi, we have a problem with open connections and hope that someone here could give me hint where to find a solution.
    The situation is that we open a connection from a Java application to an AS ABAP. In detail, the application first connects to a statefull session bean on the AS Java by RMI. The bean communicates with the associated AS ABAP by the Java Resource Adapter (JRA).
    All interactions between all components work correctly. But even after we close the application, manually close of the connections (on side of the AS Java) , remove all created and used session beans there are still open connections between the AS ABAP and the AS Java.
    The transaction smgw (Gateway Monitor) shows open connections from jlaunch to our local SAP gateway using the internal communication protocol. Obviously, the established connections are not closed, even when they are open for a week or longer.
    After opening 100 connections, the AS ABAP denies additional connection attempts.
    We have been able to close all open connections by restarting the AS Java or by restarting the Connector over the Visual Administrator (path: Cluster – Server – Services – Connector Container – “select the right connector” – stop / start).
    We have developed our application similar to the tutorial from [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4]
    Can someone explain to us why the connections stay open for so long? Is there no timeout mechanism? Or is there some way to close the connections from our Java application?

    Hello,
    maybe someone can help us with our problem.
    We have developed our application similar to the tutorial from https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4 and it was running without problem with the SP12, now we change our system to SP16 and we are having the problem described in note 1083348, but as you can see, for us it was working with SP12 and now it doesn't work with SP16....
    Here is part of our code....
        public List getAll() {
            String functionName = "bla";
            try {
                openConnection();
                MappedRecord response = (MappedRecord) interaction.execute(null, request);
                MappedRecord record = (MappedRecord) response.get("E_S_RETURN_CODE");
                if (((String) record.get("RETURN_CODE")).equalsIgnoreCase("E")) {
                    throw new SQLException((String) record.get("RETURN_TXT"));
            catch (ResourceException exc) {
                throw new EJBException(".");
            catch (SQLException exc) {
                throw new EJBException(".");
            finally {
                closeConnection();
        protected void openConnection() {
            try {
                connection = connectionFactory.getConnection();
                interaction = connection.createInteraction();
            catch (ResourceException exc) {
                interaction = null;
                connection = null;
                throw new EJBException(getExceptionText(exc));
      protected void closeConnection() {
           try {
                if (interaction != null) {
                    interaction.close();
                if (connection != null) {
                    connection.close();
            catch (ResourceException exc) {
                throw new EJBException(".");
    With that code we are getting this error: "Connection handle is already closed and no longer associated with a managed connection" everytime we try to close the connection in the method closeConnection().
    We were thinking that maybe we should not close the connections, because the were already close, and tried not to close the connection (connection.close()), but then after a few time we are getting the following error, because we are not closing the connections:
    Connection to ABAP System could not be opened, because the Connection Factory returns "Cannot get connection for 120 seconds. Possible reasons: 1) Connections are cached within SystemThread(can be any server service or any code invoked within SystemThread in the SAP J2EE Engine), 2) The pool size of adapter "eis/..." is not enough according to the current load of the system or 3) The specified time to wait for connection is not enough according to the pool size and current load of the system. In case 1) the solution is to check for cached connections using the Connector Service list-conns command, in case 2) to increase the size of the pool and in case 3) to increase the time to wait for connection property. In case of application thread, there is an automatic mechanism which detects unclosed connections and unfinished transactions.". Please check the connection defined for the Connection Factory of the Java Resource Adapter with JNDI name...
    Any help?

Maybe you are looking for