Exception when connecting to an OracleDB via an Android app

Hi everyone,
I am coding an Android app. This app has to get datas from an Oracle DB available on the LAN. So, I use JDBC to connect to the database. (ojdbc14.jar added in my Android Project). I've made 2 classes : OracleDB with the following code (http://pastebin.archlinux.fr/432146) and the "launcher class", JDBCAndroid, with that code : http://pastebin.archlinux.fr/432148.
The program, when it's a simple Java Project is able to connect to the database ; but in an Android Project, as you can see in the pastebin of the JDBCAndoid, there is "some" Exception from the driver.
In particulary, this one :
04-22 08:17:52.509: ERROR/AndroidRuntime(346): Caused by: java.lang.ArrayIndexOutOfBoundsException
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.T4CTTIoauthenticate.setSessionFields(T4CTTIoauthenticate.java:1019)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.T4CTTIoauthenticate.<init>(T4CTTIoauthenticate.java:186)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:354)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:454)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:802)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at java.sql.DriverManager.getConnection(DriverManager.java:180)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at java.sql.DriverManager.getConnection(DriverManager.java:214)
04-22 08:17:52.509: ERROR/AndroidRuntime(346): at com.example.OracleDB.connect(OracleDB.java:36)
Could someone help me to fix this ? Finally, is it possible to connect to an OracleDB from an Android app ?
other details : the server is an Oracle 10g 10.2, and the driver is ojdbc14.jar (version corresponding with the version of the server).
Best regards

854166 wrote:
this.url = new String("jdbc:oracle:thin:@192.168.1.139:1521:dev");
That IP is a private IP.
This app is very particular. It'll be use only in a restricted LAN (with the database Oracle in this LAN). So, no connection by the Internet to the database. That's why webservice is not the good solution for me. The direct connection to the OracleDB is, I think, the best solution, but I've to fix this problem...Since I haven't done any mobile programming I can't be sure but that looks extremely unlikely to me.
A mobile/cell doesn't connect to a local network. It connects to a service provider which does a redirect, via the internet. Thus a local (private IP) connection cannot work. (That is what the 'data' fee is for.)
Now if and only if the mobile has a true wireless modem in it then it would need to connect to a lan wireless router which itself was set up to do a local redirect. So two points of failure there: the wireless modem and the lan router. If either is not set up then it will fail.
And if you have a wireless modem on your dev box then you can test the connectivity from there to the database just as the mobile would. To be safe yank your network cable before testing.

Similar Messages

  • Can I connect to an OracleDB via an Android app?

    Hi,
    I originally resurrected an old long-finished forum thread and attempted to hijack it away for my own issue but a kind forum moderator has split my question away so that it might stand on its own merits (or not). I'll try to remember for the future that if I have a question, I should always make my own new forum post.
    That thread was ...
    Exception when connecting to an OracleDB via an Android app
    Is that possible to connect to other DB from android. I m a trainee and I m trying to connect android with other DB's except SQLite.. if so can anyone explain 1. how to do that, and
    2.what are the DB's can be connected with android...
    3.What is the concept behind to work it out...
    pls explain it a bit detail, as i m learning it would be easier for me to understand the concepts in better way.

    Same as what I said in the other thread.
    Either there is an IP stack or there isn't.
    If there is then you have the same problems with IP stacks as with a desktop in that it must have connectivity from the client to the database. Other than that you just use a JDBC (java only) driver.
    If there is no IP stack then you MUST look for another solution or look into creating your own solution (if possible.)

  • Issue with 2wire dsl router when connecting power pc g4 via ethernet

    Issue with 2wire dsl router when connecting power pc g4 via ethernet. The 2wire will keep resetting. When I connect my macbook pro via ethernet to the 2wire all is ok, but as soon as i connect the power pc. . . .reset. I have emailed 2wire support. They recommended using a different patch cable. Tried that.. .. anyone else having this issue???? Any help would be appreciated. . .

    Search the discussions for issues with 2wire dsl routers. This has come up before in a discussion I've been involved with, but probably not to do with the MDD. I do remember it being a design issue with the router, something that was done to it before dispatch.
    Let us know if you can't find it and we'll have a look.
    If you afford it, bin the 2wire and go buy something decent like a Netgear.

  • How do I set up my iPhone 4s to sync automatically to iTunes when connected to my iMac via USB?

        How do I set up my iPhone 4s to sync automatically to iTunes when connected to my iMac via USB?  Currently it only syncs when I manually click on sync.
        Somehow I do have my 5th gen. iPod set up to sync automatically with the same iTunes / computer.  But I do not actually see a checkbox for either device.
        (yes, the 'prevent devices from automatically syncing' is unchecked)
    thank you!

    Turn off mobile data?
    Talk to your carrier about the usage increase.
    Googling provides many tips- https://www.google.com/search?q=reduce+iPhone+data+usage&ie=utf-8&oe=utf-8

  • Cant open web pages when connected to the internet via Telstra's Pre Paid WiFi has anyone else had the same issues works fine with BigPond WiFi

    Cant open web pages when connected to the internet via Telstra's Pre Paid WiFi (this connection is working on other devices) has anyone else had the same issues, works fine with BigPond Wifi

    and now, when i tried to check again my network preference below the airport tab is showing a message that
    "my airport does not have an IP address and cannot connect to the internet!"
    then after seconds it will goes back to the first message that
    "airport has the self assigned IP address etc....."
    i don't know whats going on now!
    airport tab is not showing green color anyway! i'ts always in yellow!
    i tried turning it on and off but nothing happen! HEEELLLLPP!!!!

  • Best settings when connected to am amplifier via digital i/o

    There are all these crazy settings on the creative software and of course my amp has crazy settings as well. Wondering whats the best settings in the software so I am not "double processing" my soud. Seems to me I would want a neutral choice going to my nice amp to start with. something like default to av reciever so the reciever would process an unmodified signal. so not even perhaps make speaker choices dolby choices adc filtering effects et al. Now I know then I wouldnt be taking advantage of the cool software, but once set up a neutral connection I could mess around with the software.
    Any help and or opinion would be wonderful. Over and out.

    @Re: best settings when connected to am amplifier via digital i/ow of note and interesting is my Amplifier Harman Kardon avr320?displays PCM and 96 KHZ, not sure exactly what this means but I will be posting at audiogon and/or AVForums maybe look at audiholics to figure out if I really have the best case scenario here. Somewhere I read I would be better off with just bitstream.....which is what Ibelieve I selected?selected in soundblaster software.....things sound about as good as I can imagine but I'll check back in.
    I think Pandora one only streams at 48khz anyways. Not sure about Netflix. Looks like dvds can have even higher bitrates especially foy stereo. A yi yi, I think I'll just listen a bit to the bits.
    much is explained here, yikes its a heavy read perha
    ps.
    I just glanced.
    http://en.wikipedia.org/wiki/DVD-Audio

  • My iphone won't download apps when connected to wifi or 3g, this includes apps previously on the phone any ideas?

    My iphone won't download apps when connected to wifi or 3g, this includes apps previously on the phone any ideas?
    It goes to download then stops just showing the cloud and arrow

    Yes we are connected.  I even tried by connecting to the computer thru iTunes.  It is not working for either of us.  Just says unable to download at this time.  I was able to connect and restore my apps from my old iPhone buy it won't let me add new ones for do update on the old apps.

  • Several weeks ago I was forced to change my Apple ID when my e-mail address changed.  I spent several hours resetting all of my devices.  The new ID seems to be recognized everywhere except when I'm asked to enter it for app on my computer.

    Several weeks ago I was forced to change my Apple ID when my e-mail address changed.  I spent several hours on the phone with a tech resetting all of my devices.  The new ID seems to be recognized everywhere except when I'm asked to enter it for app upgrades on my Mac-Pro (10.8.5).  When I'm asked to sign in there, the old e-mail address is still shown and I'm unable to change it.  Suggestions?

    I was forced to change my Apple ID when my e-mail address changed. 
    There is no such requirement.
    You have created an additional Apple-ID, which is different from the one under which you purchased Items from The Mac App Store.
    Go back, log in under the OLD Apple-ID and Add an additional email Address there instead.
    Apple does not yet have a convenient way of combining Apple-IDs.

  • When will we be able to create Android Apps with DPS single edition?

    When will we be able to create Android Apps with DPS single edition?

    It's something that we would like to do, but it is unlikely to happen during the first half of 2013.
    Neil

  • When connecting to file server via smb shows no space available! Help!

    We are running an XSERVE with Mac OS X 10.5.5 and have multiple clients that connect to it (mac and windows).
    For some reason yesterday one of the clients (10.4.11) when connects to the file share using the smb protocol shows up with 0kb available and he is not able to copy any files. Every other computer shows 4TB available. When I connect to the share on his machine using my credentials I get the same problem. However, when I connect using his credentials on my machine it shows up correctly with 4TB free. Also, when he connects via AFP it shows the full 4TB. Any idea what could be causing this?
    (the reason he connects via smb is because for some reason the people on 10.4.11 experience very slow AFP transfers sometimes. If anybody knows whats causing this that would help too hehe) Thanks in advance to anyone that takes the time to help me.

    If it is an identical machine, put the machine that works fine into target disk mode and boot the machine that is having issues from the other machines drive. That will eliminate most hardware issues.
    My guess is it is a system file or a settings file in the users library. I have fixed several issues like this on computers that were running 10.4 I believe and think they were upgraded from 10.3 by someone else. The issue had something to do with permissions and files.
    Try some of the following:
    - create a new user on the computer and see if that user works. if so, it's something in the user folder (most likely User/username/Library/). If not, then it is something outside the user folder.
    Try
    - running a combo Update on the machine
    - run disk utility file and permissions on the drive
    - Backup the user folder and clone the drive that works onto this drive, and move the user folder over. (assuming you know how to do that, it is easy)
    REGARDING Slow AFP - having the same issue with 10.4.11 Server. Most clients are Leopard. Intermittent, so hard to diagnose. Tried several solutions on this wait and see issue.

  • Error when connecting to SQL*PLUS via ODBC to Excel

    OS: Windows 2000 Professional
    Oracle DB: 9i release 2
    SQL*Plus: Release 9.2.0.1.0
    MS Excel: 2000
    ===================
    When I try to connect to SQL*PLUS via ODBC to Excel with "connect scott/tiger@odbc:libro" I get the following error:
    ORA-03121: no interface driver connected - function not performed

    SQL Server objects are commonly case sensitive, so please surround the column and table names by double quotes:
    SELECT "Type_PK_ID" FROM "dbo"."boundaries"@sqlserver
    SIDE NOTE: Oracle is by default not case sensitive and all object names are stored in upper case. To get case sensitive objects they need to be surrounded by double quotes. In HSODBC case sensitive table names were commonly found even when not surrounded by double quotes as the gateway used internal SQL Server methods to find the correct table nameing - this method does not work for column names. So to be able to query a case sensitive column it needs to be surrounded by double quotes and the table name must be written as stored in the source database.

  • Sql exception when connecting to oracle database

    When trying to connect to an oracle database using the code below i get an sql error. i put the code below it and the stack trace below the code. any help would be great
    Connection connection = null;
            try {
                // Load the JDBC driver
                String driverName = "oracle.jdbc.driver.OracleDriver";
                Class.forName(driverName);
                //  Create a connection to the database
                String serverName = "192.168.0.2";
                String portNumber = "1158";
                String sid = "orcl";
                String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
                // String url = "jdbc:oracle:oci:@orcl";
                String username = "system";
                String password = "mmsi";
                connection = DriverManager.getConnection(url, username, password);
            } catch (ClassNotFoundException e) {
                System.out.println("Class Not Found Exception in connection to db");
            } catch (SQLException e) {
                System.out.println("SQL Exception in connecting to Database ");
                e.printStackTrace();
    stackTrace------------------------------------------------------------------------------
    java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    SQL Exception in connecting to Database
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
            at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
            at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
    before this.start
    got to doaction
            at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:420)
            at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
            at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
            at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
            at java.sql.DriverManager.getConnection(DriverManager.java:525)
            at java.sql.DriverManager.getConnection(DriverManager.java:171)
            at mmsiserver.conversation.<init>(conversation.java:190)
            at mmsiserver.Server.run(Server.java:105)
    Exception in thread "Thread-0" java.lang.NullPointerException
            at mmsiserver.conversation.doAction(conversation.java:218)
            at mmsiserver.conversation.<init>(conversation.java:202)
            at mmsiserver.Server.run(Server.java:105)Message was edited by:
    pcpitcher1

    Please read this
    http://forum.java.sun.com/thread.jspa?threadID=512566&start=0&tstart=0

  • Non-Deterministic Exception When Connecting With Wrong Client Certificate

    I am working on an internal application and need to determine the correct client-side SSL certificate to use when connecting to a server (the user can supply multiple client-side certificates). I had expected that if I connected to a server using the wrong client certificate the java client would throw a SSLHandshakeException and I could then try the next certificate. This seems to work some of the time, however the java client will sometimes throw a “SocketException: Software caused connection abort: recv failed”, in which case it is not possible to know that the wrong certificate caused the problem.
    Below is the code I have been using to test as well as the intermittent SocketException stack trace. Does anyone have an idea as to how to fix this problem? Thanks in advance.
    Note: the TrustAllX509TrustManager is a trust manager that trusts all servers.
    protected void connectSsl() throws Exception {
          final String host = "x.x.x.x";
          final int portNumber = 443;
          final int socketTimeout = 10*1000;
          // Note: Wrong certificate (expect SSLHandshakeException).
          final String certFilename = "C:\\xxx\\clientSSL.P12";
          final String certPassword = "certPassword";
          final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(new File(certFilename)));
          final char[] certificatePasswordArray = certPassword.toCharArray();
          final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
          final KeyStore keyStore = KeyStore.getInstance("PKCS12");
          keyStore.load(bis, certificatePasswordArray);
          keyManagerFactory.init(keyStore, certificatePasswordArray);
          final KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
          final SSLContext context = SSLContext.getInstance("SSL");
          context.init(keyManagers, new TrustManager[]{new TrustAllX509TrustManager()}, new SecureRandom());
          final SocketFactory secureFactory = context.getSocketFactory();
          final Socket socket = secureFactory.createSocket();
          final InetAddress ip = InetAddress.getByName(host);
          socket.connect(new InetSocketAddress(ip, portNumber), socketTimeout);
          socket.setSoTimeout(socketTimeout);
          // Write the request.
          final OutputStream out = new BufferedOutputStream(socket.getOutputStream());
          out.write("GET / HTTP/1.1\r\n".getBytes());
          out.write("\r\n".getBytes());
          out.flush();
          InputStream inputStream = socket.getInputStream();
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          byte[] byteArray = new byte[1024];
          int bytesRead = 0;
          while ((bytesRead = inputStream.read(byteArray)) != -1) {
             outputStream.write(byteArray, 0, bytesRead);
          socket.close();
          System.out.println("Response:\r\n" + outputStream.toString("UTF-8"));
       }Unexpected SocketException:
    main: java.net.SocketException: Software caused connection abort: recv failed
         at java.net.SocketInputStream.socketRead0(Native Method)
         at java.net.SocketInputStream.read(SocketInputStream.java:129)
         at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:293)
         at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:331)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:789)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1435)
         at com.sun.net.ssl.internal.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:103)
         at com.sun.net.ssl.internal.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:612)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:808)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:734)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:197)
         at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:516)
         at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:454)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:884)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1096)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:623)
         at com.sun.net.ssl.internal.ssl.AppOutputStream.write(AppOutputStream.java:59)
         at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
         at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)

    Thanks for the quick response. Here are answers to the questions:
    1) No, this issue is not associated with one particular certificate. I have tried several certificates and see the same issue.
    2) I agree it would be simpler to only send the required certificate, but unfortunately the project requires that the user be able to specify multiple certificates and, if a client-side certificate is required, the application try each one in turn until the correct certificate is found.
    3) Yes, I realize the TrustAllX509TrustManager is insecure, but I am using this for testing purposes while trying to diagnose the client certificate problem.
    In terms of testing, I am just wrapping the above code in a try/catch block and executing it in a loop. It is quite odd that the same exact code will sometimes generate a SSLHandshakeException and other times a SocketException.
    One additional piece of information: if I force the client code to use "SSLv3" using the Socket.setEnabledProtocols(...) method, the problem goes away (I consistently get a SSLHandshakeException). However, I don't think this solves my problem as forcing the application to use SSLv3 would mean it could not handle TLS connections.
    The code to specify the SSLv3 protocol is:
    SSLSocket sslSocket = (SSLSocket) socket;
    sslSocket.setEnabledProtocols(new String[] {"SSLv3"});
    One other strange issue: if instead of specifying the SSLv3 protocol using setEnabledProtocols(...) I instead specify the protocol when creating the SSLContext, the SocketException problem comes back. So if I replace:
    final SSLContext context = SSLContext.getInstance("SSL");
    with:
    final SSLContext context = SSLContext.getInstance("SSLv3");
    and remove the "sslSocket.setEnabledProtocols(new String[] {"SSLv3"})" line, I see the intermittent SocketException problem.
    All very weird. Any thoughts?

  • Can I use AirPlay from my PC to my AppleTV when connected to an AirPort via LAN cable?

    Well as stated above I'm wondering if I can use AirPlay from my PC to my AppleTV when my PC is connected via LAN cable to an AirPort.
    I'm asking because usually your PC has to be on the same Wifi as your other Apple device, so AirPlay can function, and id love the ability to Stream via AirPlay but still be connected to the internet via LAN cable.
    Thanks in advance for any help!

    AirPlay is not restricted to wireless only. It can also work over Ethernet. Basically as long as there is a connection (on the same subnet) between the iTunes host and the AirPlay "speaker" streaming should take place without any issues.
    FWIW, My Win8 PC is connected to a Time Capsule via Ethernet. In turn my Apple TV is connected to the TC's wireless network. I have no trouble streaming from the PC to the Apple TV in this configuration.

  • Blackberry Z10 not sending/receiving emails or able to browse when connected to WiFi only via mobile network?

    I have today moved from Windows Mobile device to BB Z10 and am hvaing difficutlies as cannot send/receive emails or browse when connected to work WiFi and only works via mobile network. WiFi works absolutely fine with all other devices including my previous Windows mobile but am concerned that nothing works when I connect to work WiFi as trying to keep data usage to a minimum.
    Emails are coming in via Exchange Activesync in case that makes a difference and was only able to get that working when turned WiFi off when setting up as well.
    Please help as mobile signal poor at home and have to rely on WiFi connections to get emails and essential i get them as cover a security support queue.........

    Hello michellef,
    Thank you for your question.
    Have you attempted connecting to a different Wi-Fi network as a test? 
    The following post from our Inside BlackBerry Help Blog may assist you with troubleshooting the issue:
    http://helpblog.blackberry.com/2013/02/wi-fi-connectivity-issues/
    Let us know if this helps!
    -FB
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click "Accept as a Solution" for posts that have solved your issue(s)!

Maybe you are looking for

  • When is the h.264 bit rate issue going to be fixed?

    If you export a project in After Effects using the H.264 codec the file you export does not have the correct bitrate. Meaning if you export a video at 1mbps compression rate you will not get a video that has 1mbps bitrate. This has been an issue sinc

  • [SOLVED] Can't mount my root file system on boot!

    Posting from an Ubuntu install on the same machine. So, my root partition, labeled "arch", is ext4 on /dev/sda5. My home partition is btrfs on /dev/sda1. When I boot, I get this error: http://imgur.com/mzmLIZH Not sure what to do from there. I can mo

  • Pyament guarantee

    hi,       can any one explain about the <b>payment guarantee</b> procedure in detail thanx in advance

  • Why does Flash install Google Toolbar?

    Why does Flash install Google Toolbar? Honestly, do you have ANY idea how annoying that behaviour is? I had no option at all to not download it, I could not stop downloading it. I was taking from a "you need to install flash" button on Facebook to th

  • "No action " Status in FEP 2010 Report

    Hi Team, We need a clarification about the FEP 2010 options as below: Our internal security team raised an Point that what does "No action" actions specify here,which notified in FEP reports. There it says 1 system status is "No action",however there