fishScript.com d
Home| Progetto| Web| Faq| Acronimi

Argomenti

Documenti pubblicabili:1120
Scripts:1282
Documenti non pubblicabili:162
Categorie tematiche:68
.Net
   |_C#
   |_Visual basic.net
   |_Asp.net
Active Server Pages
C++
Cascade Style Sheet
JavaScript
Mysql
Php
Xml
Java
   |_Java 2 Micro Edition
   |_Java server pages
   |_Java Servlet
Oracle
   |_PLSQL
PostgreSQL
Unix



Oracle... Script: dbms_output.put_line



PLSQL... Script: Cursore, open, fetch
Java... Tip: Il parametro verbose

Shell scripting... Script: Compact if construct

A User Agent, like a web browser, uses HTTP to request a HTML document



In programming the danger of exploring the small details of coding is that you get obsessed with every line of code you write, thereby greatly reducing productivity.
In general, is not worth obsessing over code.
On the other hand you should code with deliberation and intent. Steven Feurstein Oracle Magazine July /August 2004

A User Agent, like a web browser, uses HTTP to request a HTML document

Java

Home >Java > Java program connecting to Oracle Database using jdbc driver

Stampa  Stampa


Basic example java program connecting to Oracle Database using jdbc driver.

1) make sure your java enviroment is properly set.

2) create java source file testOrajdbc.java

//testOrajdbc.java
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;

class testOrajdbc
{
   public static void main (String args[])
          throws SQLException
   {
   OracleDataSource ods = new OracleDataSource();
   //oracle coordinates:schema name, password, hostname/ip, db port and SID
   ods.setURL("jdbc:oracle:thin:pbs01/pbs01@10.12.8.3:1521/CUST01");
   Connection conn = ods.getConnection();

      // Create Oracle DatabaseMetaData object
      DatabaseMetaData meta = conn.getMetaData();
      Statement stmt = conn.createStatement();

      // gets driver info:
      System.out.println("JDBC DRIVER VERSION:  " + meta.getDriverVersion());

      // a select query
      ResultSet rset = stmt.executeQuery ("SELECT GLOBAL_NAME FROM GLOBAL_NAME");
      while (rset.next()) {
      System.out.println("DATABASE NAME  = " + rset.getString(1));
      }
   }
}
	


3) Make sure your enviromeent include reference to oracle java jdbc library, you simply need to add to your CLASSPATH variable $ORACLE_HOME/jdbc/lib/classes12.jar, in unix HP for example:

export CLASSPATH=$CLASSPATH:/opt/oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar


4) Compile the java program, the output should be the executable file testOrajdbc.class.

$ javac testOrajdbc.java


5) Run the java program testOrajdbc.class anc check the output:

$ java testOrajdbc

JDBC DRIVER VERSION: 10.2.0.4.0 DATABASE NAME = CUST01




Warning: include(ads/text468x15.html): failed to open stream: No such file or directory in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131

Warning: include(): Failed opening 'ads/text468x15.html' for inclusion (include_path='.;C:\php\pear') in D:\inetpub\webs\fishscriptcom\documents\view_document.php on line 131

Tutorial
Scrivere ed installare midlet in un telefono cellulare (parte III) Trasferimento della Midlet su attraverso scheda di memoria  [Java 2 Micro Edition] 
HelloWorld Iniziare la programmazione di Midlet  [Java 2 Micro Edition] 
Un midlet per estrarre numeri vincenti visualizza su un dispositivo mobile interi pseudorandom  [Java 2 Micro Edition] 
Scrivere ed installare midlet in un telefono cellulare (parte I) Compilazione e test di una Midlet con il J2ME Wireless Toolkit ed installazione dell'applicazione nel telefono mobile   [Java 2 Micro Edition] 
Scrivere ed installare midlet in un telefono cellulare (parte II) Trasferimento della Midlet su dispositivo mobile attraverso collegamento cavo e Midway   [Java 2 Micro Edition] 
Java program connecting to Oracle Database using jdbc driver Basic example compiling and executing jdbc Oracle connection  [Java] 
Manipolazione tipi date formattare data e ora  [Java] 
Script
Operazioni sulle stringhe Manipolazioni fondamentali  [Java server pages] 
Reading data from xml file Parsing xml  [Java server pages] 
Stampa della data La data corrente  [Java server pages] 
Ricavare informazion sul sistema operativo Oggetto system  [Java server pages] 
Test connessione ad Oracle Operazioni sui database  [Java Servlet] 
Example mysql connection Mysql connection   [Java server pages] 
ResultSet retriving data from a table Extract rows from a database (mysql)  [Java server pages] 
Saving data in mysql trought a form Getting user data and save them on a database  [Java server pages] 
Creating a Cookie Creating and assignig value to a cookie  [Java server pages] 
Including files Fundamental directives  [Java server pages] 
Test MySql connection Operazioni sui database  [Java Servlet] 
My First Servlet Beginning with servlet  [Java Servlet] 
Make your choice Reading keyboard input from console  [Java] 
Fai la tua scelta Ricevere input da tastiera  [Java] 
Classi Creazione ed utilizzo  [Java] 
Comandi
Inclusione di un file Direttiva page include  [Java server pages] 
Indirizzo remoto / Remote Address Oggetto request  [Java server pages] 
Nome server / Server Name Oggetto request  [Java server pages] 
Locale Oggetto request  [Java server pages] 
Porta del Server / Server Port Oggetto request  [Java server pages] 
Ricavare il metodo della richiesta della pagina Post o get? Ogetto request  [Java server pages] 
Ricavare il protocollo utilizzato dalla richiesta Oggetto request  [Java server pages] 
Servlet path Oggetto request  [Java server pages] 
Remote host Oggetto request  [Java server pages] 
Jar (comprimere le classi)   [Java] 

signal Marco Magnani marcomagnani@fishscript.com



Cerca





Anger is creative, depression is useless.
Dyson, Freeman J.


Anger is creative, depression is useless.
Dyson, Freeman J.



Java... Definizioni: Java Bean

Oracle... Definizioni: Set di caratteri (Characterset)


Shell scripting... Script: Array



fishScript.Com is accessible by Mobile access technology as mobile phones, Palm and Pocket PC .

Nicoleta e Marco Magnani tutorial, examples, courses, esempi, corsi, esercizi, appunti vari Dottoressa Nicoleta Dragu Formatrice Docente Insegnante Mediatrice Culturale Dott. Marco Magnani Universita La Sapienza Roma Master Computer Science Hunter College New York , Data Base Administrator DBA oracle System architect

Last modified: 2017-11-30 amministratore@fishscript.comNico and Marco Magnani Software Production
Home|About this Site © 2003-2008 www.fishScript.com ®