Package javax.sql

Examples of javax.sql.DataSource


         UserTransaction ut = sessionCtx.getUserTransaction();
         ut.setTransactionTimeout(5);
         ut.begin();
         try
         {
            DataSource ds = (DataSource) ctx.lookup("java:DefaultDS");
            Connection c = ds.getConnection();
            try
            {
               Statement stmt = c.createStatement();
               stmt.executeUpdate("insert into JCA_TRANSACTION_ACTIVE values ('101')");
               try
View Full Code Here


         InitialContext ctx = new InitialContext();
         UserTransaction ut = sessionCtx.getUserTransaction();
         ut.begin();
         try
         {
            DataSource ds = (DataSource) ctx.lookup("java:DefaultDS");
            Connection c = ds.getConnection();
            try
            {
               Statement stmt = c.createStatement();
               ResultSet rs = stmt.executeQuery("select name from JCA_TRANSACTION_ACTIVE");
               if (rs.next() == false)
View Full Code Here

   {
      Connection lConnection = null;
      PreparedStatement lStatement = null;
      try {
         Object lTemp = new InitialContext().lookup( mDataSourceName );
         DataSource lDB = (DataSource) lTemp;
         lConnection = lDB.getConnection();
         lStatement = lConnection.prepareStatement( mSQLStatement );
         ResultSet lResult = lStatement.executeQuery();
         while( lResult.next() ) {
            int lID = addSchedule(
               new ObjectName( lResult.getString( 1 ) ),
View Full Code Here

   }

   public void testDefaultFormattedStatistics() throws Exception{
     
      InitialContext initCtx = super.getInitialContext();
      DataSource ds = (DataSource)initCtx.lookup("StatsDS");
      Connection conn = ds.getConnection("sa", "");
     
      Object formattedStats = StatisticsHelper.listFormattedStatistics(getServer());

      assertTrue(formattedStats instanceof String);
     
View Full Code Here

      assertTrue(beforeStats instanceof String);
      assertEquals(beforeStats, expectedBeforeBuffer.toString());

      // Obtaining connections
      DataSource ds = (DataSource)initCtx.lookup("StatsDS");
      Connection conn1 = ds.getConnection("sa", "");
     
      Object conn1Stats = StatisticsHelper.listFormattedStatistics(getServer());

      assertTrue(conn1Stats instanceof String);

      Pattern p1 = Pattern.compile(expectedConn1Buffer.toString());
      Matcher m1 = p1.matcher((String)conn1Stats);

      assertTrue(m1.matches());

      Connection conn2 = ds.getConnection("sa", "");
     
      Object conn2Stats = StatisticsHelper.listFormattedStatistics(getServer());

      assertTrue(conn2Stats instanceof String);
View Full Code Here

  

   public void testXmlFormatterStatistics() throws Exception{

      InitialContext initCtx = super.getInitialContext();
      DataSource ds = (DataSource)initCtx.lookup("StatsDS");
      Connection conn = ds.getConnection("sa", "");

      setStatisticsFormatter(XML_FORMATTER);
      Object formattedStats = (String)getServer().invoke(POOL_NAME, FORMATTED_STATS_METHOD, new Object[0], new String[0]);
     
      assertTrue(formattedStats instanceof String);
View Full Code Here

   public void testInvalidFormatter() throws Exception{

      ObjectName name = new ObjectName("jboss.jca:service=ManagedConnectionPool,name=StatsDS");     
     
      InitialContext initCtx = super.getInitialContext();
      DataSource ds = (DataSource)initCtx.lookup("StatsDS");
      Connection conn = ds.getConnection("sa", "");
      setStatisticsFormatter("Invalid");
     
      Object formattedStats = (String)getServer().invoke(POOL_NAME, FORMATTED_STATS_METHOD, new Object[0], new String[0]);
     
      assertTrue(formattedStats instanceof String);
View Full Code Here

  /* (non-Javadoc)
   * @see net.sourceforge.jdbclogger.demo.AbstractJdbcLoggerDemo#getConnection()
   */
  @Override
  protected Connection getConnection() throws SQLException {
    DataSource dataSource = (DataSource)applicationContext.getBean(DATA_SOURCE_BEAN_NAME);
    return dataSource.getConnection();
  }
View Full Code Here

      System.out.println("Converting zone " + zone.getSOA().getName().toString() + "...");

      dbZones.add(new DBZone(zone,false));
    }

    DataSource dataSource = new SimpleDataSource(driver, url, username, password);

    SimpleAnnotatedDAOFactory annotatedDAOFactory = new SimpleAnnotatedDAOFactory();
    AnnotatedDAO<DBZone> zoneDAO  = new AnnotatedDAO<DBZone>(dataSource,DBZone.class, annotatedDAOFactory);
    AnnotatedDAO<DBRecord> recordDAO  = new AnnotatedDAO<DBRecord>(dataSource,DBRecord.class, annotatedDAOFactory);
View Full Code Here

  public void init(String name) throws ClassNotFoundException {

    this.name = name;

    DataSource dataSource;

    try {
      dataSource = new SimpleDataSource(driver, url, username, password);

    } catch (ClassNotFoundException e) {
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.