Package javax.sql

Examples of javax.sql.DataSource


         // But we should NOT be able connect to TestDataSource1
         try
         {
            InitialContext ic = new InitialContext();
            DataSource ds1 = (DataSource) ic.lookup(jndiName1);
            fail("Shouldn't reach this point");
         }
         catch (Exception e)
         {
            // Ok, remove the file
View Full Code Here


    */
   private boolean connectToDataSource(String jndiName) throws Exception
   {
      boolean connected = false;
      InitialContext ic = new InitialContext();
      DataSource ds = null;
      Connection connection = null;

      // See if we can get a connection
      for (int tries = 0; tries < 5; tries++)
      {
         try
         {
            ds = (DataSource) ic.lookup(jndiName);
            connection = ds.getConnection();
            connection.close();
            connected = true;
            log.info("Connected to data source: " + jndiName);
            break;
         }
View Full Code Here

      }
   }

   private void jdbcUpdate(String id, int value) throws Exception
   {
      DataSource ds = getDS();
      Connection con = null;
      Statement st = null;
      try
      {
         con = ds.getConnection();
         st = con.createStatement();
         int rows = st.executeUpdate("update TEST_A set INT_FIELD=" +
            value + " where ID='" + id + "'"
         );
         if(rows != 1)
View Full Code Here

      ManagedConnectionFactory mcf = new TestManagedConnectionFactory();
      SimpleMetaData metadata = new SimpleMetaData();
     
      metadata.addMetaData(ConnectionFactoryInterceptor.CONNECTION_FACTORY, ConnectionFactoryInterceptor.CONNECTION_MANAGER, cm);
      metadata.addMetaData(ConnectionFactoryInterceptor.CONNECTION_MANAGER, ConnectionFactoryInterceptor.MANAGED_CONNECTION_FACTORY, mcf);
      DataSource ds = (DataSource) assertCreateHollowProxy(new Class[] { DataSource.class }, metadata, DataSource.class);
      Connection c = ds.getConnection();
      assertNotNull(c);
      assertTrue(c instanceof TestConnection);
      TestConnection tc = (TestConnection) c;
      assertNotNull(tc.getManagedConnectionFactory());
      assertTrue(mcf == tc.getManagedConnectionFactory());
View Full Code Here

      try
      {
         if( methodClass.isAssignableFrom(DataSource.class) )
         {
            InitialContext ctx = new InitialContext();
            DataSource ds = (DataSource) ctx.lookup(bindName);
            value = doDataSourceMethod(ds, method, args);
         }
         else if( methodClass.isAssignableFrom(Connection.class) )
         {
            Object id = invocation.getId();
View Full Code Here

   }

   private void testJdbcDataSource(Context initCtx, Context myEnv) throws NamingException
   {
      // JDBC DataSource
      DataSource ds = (DataSource) myEnv.lookup("jdbc/DefaultDS");
      log.debug("jdbc/DefaultDS = " + ds);
   }
View Full Code Here

         props.put("user", "sa");
         conn = driver.connect(jdbcURL, props);
      }
      else
      {
         DataSource datasource = (DataSource) new InitialContext().lookup(getDataSourceJndiName());
         conn = datasource.getConnection();
      }
      return conn;
   }
View Full Code Here

   }

   private void testJdbcDataSource(Context initCtx, Context myEnv) throws NamingException
   {
      // JDBC DataSource
      DataSource ds = (DataSource) myEnv.lookup("jdbc/DefaultDS");
      log.debug("jdbc/DefaultDS = " + ds);
   }
View Full Code Here

    * @ejb.transaction type="Supports"
    */
   public void testJdbcCloseCompliance()
   {
      InitialContext ctx = null;
      DataSource ds = null;
      Connection conn = null;
      Statement s = null;
      ResultSet rs = null;
     
      try
      {
         ctx = new InitialContext();
         ds = (DataSource)ctx.lookup("java:/ComplianceDS");
         conn = ds.getConnection("sa", "");
         s = conn.createStatement();
         s.execute("CREATE TABLE DUMMY (id int, dummy varchar(10))");
         rs = s.executeQuery("SELECT * FROM DUMMY");
         s.execute("DROP TABLE DUMMY");
         rs.close();
View Full Code Here

   public void setupDatabase()
   {
      try
      {
         InitialContext ctx = new InitialContext();
         DataSource ds = (DataSource) ctx.lookup("java:DefaultDS");
         Connection c = ds.getConnection();
         try
         {
            Statement stmt = c.createStatement();
            try
            {
View Full Code Here

TOP

Related Classes of javax.sql.DataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.