Oracle database connection using jbdc


  1. mogly

    mogly New Member

    Hi all :)
    I am trying to communicate with an oracle database using jbdc, I need to read and write to the database, I dont have server access so have to commincate directly with the database. At the moment I am struggling to even get a connection. The app only needs to be simulated on a secure network so I am not too worried about security issues.
    code im using:
    Code (Text):
    1. package com.tentantrepairs;
    2.  
    3. import java.sql.Connection;
    4. import java.sql.DriverManager;
    5. import android.app.Activity;
    6. import android.os.Bundle;
    7. import android.widget.TextView;
    8.  
    9. public class TenantRepairs extends Activity{
    10.     @Override
    11.     public void onCreate(Bundle savedInstanceState) {
    12.     super.onCreate(savedInstanceState);
    13.     TextView tv = new TextView(this);
    14.     tv.setText("orcale Connect Example.");
    15.     setContentView(tv);
    16.    
    17.     Connection conn;
    18.     String url = "jdbc:oracle:thin:@blah.blah.blah.ac.uk:1522:orcl";
    19.     String userName = "PRCSF";
    20.     String password = "PRCSF";
    21.     try {
    22.         Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    23.       conn = DriverManager.getConnection(url,userName,password);
    24.       tv.setText("Connected to the database");
    25.     } catch (Exception e) {
    26.         tv.setText("nope");
    27.     }
    28.     }
    29.     }
    Many thanks Ben

    Advertisement
    :
Loading...

Share This Page