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:
    package com.tentantrepairs;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class TenantRepairs extends Activity{
    	@Override
    	public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	TextView tv = new TextView(this);
    	tv.setText("orcale Connect Example.");
    	setContentView(tv);
    	
    	Connection conn;
    	String url = "jdbc:oracle:thin:@blah.blah.blah.ac.uk:1522:orcl";
    	String userName = "PRCSF"; 
    	String password = "PRCSF";
    	try {
    		Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    	  conn = DriverManager.getConnection(url,userName,password);
    	  tv.setText("Connected to the database");
    	} catch (Exception e) {
    		tv.setText("nope");
    	}
    	}
    	}
    Many thanks Ben

    Advertisement

Share This Page