0

I am developing an android application. for doing it i need to connect to oracle database. i created a connection class as in Java. but when i try to run it nothing happens. i heard that a middle ware is needed to do this task. and also something about host. i didn’t get any clear ideas of what i should do. i have checked so many blogs and googling. but none helped. will somebody explain it to me in steps what all steps should i do to create my application? please gys i am stuck here, any blogs, posts will do

/*imports*/



public class ConnectionClass 
{
public Connection connectToDB(){

    Connection con=null;

try{
Class.forName("oracle.jdbc.driver.OracleDriver");

 con=DriverManager.getConnection(
"jdbc:oracle:thin:@blablabla:1521:bla","usr","pass");


}catch(Exception e){ System.out.println(e);}
return con;

}
public static void main(String arg[])
{
    try
    {
    ConnectionClass conDB=new ConnectionClass();
    System.out.println("connection*&% "+conDB );
    }
    catch(Exception e)
    {
        System.out.println(e);
    }

}

}

it is compiling in javac and result is obtained correctly

Mukund
  • 1,107
  • 2
  • 18
  • 40

1 Answers1

2

You can connect your oracle db or whatelse by using webservice, I mean, you can create webservice on server side, You can connect odbc to your db in your webservice and just connect webservice with get and post method from your android app, which is more safe.

1. Create webservice (for example in mvc4.5)

2. Create get or post method what you need

3. In your client,connect your webservice to post or get

For Example

create a post method in your service like this:

yourserver/my_post_insert_method/name/id

Then in your client write a post method and give name and id parameter and then your record is written to oracle db.

Sully
  • 14,672
  • 5
  • 54
  • 79
CompEng
  • 7,161
  • 16
  • 68
  • 122