Test DataSource LookUp : Oracle JDBC : Database SQL JDBC : Java examples (example source code) Organized by topic

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JSP
19. JSTL
20. Language Basics
21. Network Protocol
22. PDF RTF
23. Regular Expressions
24. Security
25. Servlets
26. Spring
27. Swing Components
28. Swing JFC
29. SWT JFace Eclipse
30. Threads
31. Tiny Application
32. Velocity
33. XML
Java Tutorial
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Database SQL JDBC » Oracle JDBCScreenshots 
Test DataSource LookUp

/*

Java Programming with Oracle JDBC
by Donald Bales 
ISBN: 059600088X
Publisher: O'Reilly

*/


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class TestDSLookUp {

  public static void main(String[] argsthrows SQLException, NamingException {

    Context ctx = null;
    try {
      Properties prop = new Properties();
      prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
          "com.sun.jndi.fscontext.RefFSContextFactory");
      prop.setProperty(Context.PROVIDER_URL, "file:/JNDI/JDBC");
      ctx = new InitialContext(prop);
    catch (NamingException ne) {
      System.err.println(ne.getMessage());
    }

    DataSource ds = (DataSourcectx.lookup("joe");
    Connection conn = ds.getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt
        .executeQuery("select 'Hello Thin driver data source tester '||"
            "initcap(USER)||'!' result from dual");
    if (rset.next())
      System.out.println(rset.getString(1));
    rset.close();
    stmt.close();
    conn.close();
  }
}

           
       
Related examples in the same category
1. Get Object From Oracle Database Using STRUCT
2. Inser BLOG(Picture or Photo) Data Type Into Oracle Database
3. Serialized And Deserialize Object Oracle
4. Get Oracle Table Names
5. Get Parameter MetaData From Oracle JDBC Driver
6. Test Oracle JDBC Driver Installation
7. Create Employee Table Oracle
8. Count row in Oracle
9. Get Column Names From ResultSet for Oracle
10. Demo ResultSet Oracle
11. All data types for Oracle
12. Get Column Privileges Oracle
13. Test OCINet 8 App
14. Test SSL
15. Test Data Encryption Integrity
16. OracleDataSource Demo
17. Register custome type to Oracle
18. Insert custom type to Oracle
19. Check JDBC Installation for Oracle
Home | Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.