• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AS400类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.ibm.as400.access.AS400的典型用法代码示例。如果您正苦于以下问题:Java AS400类的具体用法?Java AS400怎么用?Java AS400使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AS400类属于com.ibm.as400.access包,在下文中一共展示了AS400类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Test routine for fetching a spooled file list
 *
 * @param args systemName userId password userFilter
 * @see #setUserFilter(java.lang.String)
 */
public static void main(String args[]) {
    String systemName = args[0];
    String userId = args[1];
    String password = args[2];
    String userFilter = args[3];
    try {
        AS400 as400 = AS400Factory.newAS400(systemName, userId, password);
        SpooledFileLister lister = new SpooledFileLister(as400);
        lister.setUserFilter(userFilter);
        Enumeration e = lister.getSynchronously();
        while (e.hasMoreElements()) {
            SpooledFile spf = SpooledFile.class.cast(e.nextElement());
            System.out.println(spf.getName() + " " + spf.getNumber() + " " + spf.getJobName() + " " + spf.getJobUser() + " " + spf.getJobNumber() + " " + spf.getCreateDate() + " " + spf.getCreateTime());
        }
    } catch (AS400SecurityException | ErrorCompletingRequestException | IOException | InterruptedException | PropertyVetoException | RequestNotSupportedException ex) {
        LOG.log(Level.SEVERE, "Exception fetching list of spooled files", ex);
    }
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:25,代码来源:SpooledFileLister.java


示例2: main

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * A test of fetching the transformed spooled file and transforming it.
 *
 * @param args sysName userId password spoolFileName spoolNumber jobName
 * jobUser jobNumber
 */
public static void main(String[] args) {
    String sysName = args[0];
    String userId = args[1];
    String password = args[2];
    String spoolFileName = args[3];
    int spoolNumber = Integer.parseInt(args[4]);
    String jobName = args[5];
    String jobUser = args[6];
    String jobNumber = args[7];

    try {
        AS400 as400 = AS400Factory.newAS400(sysName, userId, password);
        TransformedSpooledFileFetcher fetcher = new TransformedSpooledFileFetcher(as400, spoolFileName, spoolNumber, jobName, jobUser, jobNumber);
        System.out.print(fetcher.fetchSpooledFile());
        System.out.flush();
    } catch (AS400SecurityException | PropertyVetoException | ErrorCompletingRequestException | IOException | InterruptedException | RequestNotSupportedException ex) {
        LOG.log(Level.SEVERE, "Exception fetching spooled file", ex);
    }

}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:27,代码来源:TransformedSpooledFileFetcher.java


示例3: exceptionOccurred

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Override
public void exceptionOccurred(SignonEvent event)
        throws AS400SecurityException {
    boolean reThrowing = true;
    AS400 as400 = AS400.class
            .cast(event.getSource());
    AS400SecurityException aS400SecurityException = event.getException();
    int asexRc = aS400SecurityException.getReturnCode();
    /* Debug */ Logger.getLogger(SignonHandler.class
            .getName()).log(Level.INFO, "AS400SecurityException retcode is {0}", asexRc);
    switch (asexRc) {
        case AS400SecurityException.PASSWORD_ERROR:
        case AS400SecurityException.PASSWORD_INCORRECT:
            try {
                if (pollForPassword(as400)) {
                    reThrowing = false;
                }
            } catch (IOException ex) {
                Logger.getLogger(SignonHandler.class.getName()).log(Level.SEVERE, null, ex);
            }
            break;
    }
    if (reThrowing) {
        throw aS400SecurityException;
    }
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:27,代码来源:SignonHandler.java


示例4: pollForPassword

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Polls user for a password and if gotten resets password field of as400
 *
 * @param as400 the system we are trying to get a valid password for
 * @return true if got a password from user
 * @throws IOException
 */
protected boolean pollForPassword(AS400 as400) throws IOException {
    boolean result = false;
    String passwordPrompt = "Please enter a valid password for " + as400.getSystemName() + " (will not echo):";
    char[] password;
    if (System.console() != null) {
        password = System.console().readPassword(passwordPrompt);
    } else {
        if (Ublu.ubluSingleton.isGoubluing()) {
            System.out.println(passwordPrompt);
        } else {
            System.out.print(passwordPrompt);
        }
        password = new BufferedReader(new InputStreamReader(System.in)).readLine().trim().toCharArray();
    }
    String pString = new String(password).trim();
    if (!pString.isEmpty()) {
        as400.setPassword(pString);
        result = true;
    }
    return result;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:29,代码来源:SignonHandler.java


示例5: pollForUserId

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Polls user for a userid and if gotten resets userid field of as400
 *
 * @param as400 the system we are trying to get a valid userid for
 * @return true if got a userid from user
 * @throws IOException
 * @throws PropertyVetoException
 */
protected boolean pollForUserId(AS400 as400) throws IOException, PropertyVetoException {
    boolean result = false;
    String useridPrompt = "Please enter a valid userid for " + as400.getSystemName() + ": ";
    if (Ublu.ubluSingleton.isGoubluing()) {
        System.out.println(useridPrompt);
    } else {
        System.out.print(useridPrompt);
    }
    byte[] userid = new byte[16]; // longer than real userid swallows lf
    int numRead = System.in.read(userid);
    if (numRead > 0) {
        String uidString = new String(userid).trim();
        as400.setUserId(uidString);
        result = true;
    }
    return result;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:26,代码来源:SignonHandler.java


示例6: getDriverName

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Translate type into string name of driver class
 *
 * @return Driver name so we can instance it.
 */
public String getDriverName() {
    String driverName = "";
    switch (getDbType()) {
        case AS400:
            driverName = "com.ibm.as400.access.AS400JDBCDriver";
            break;
        case PGSQL:
            driverName = "org.postgresql.Driver";
            break;
        case MSSQL:
            driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    }
    // /* Debug */ getLogger().log(Level.INFO, "Driver name is " + getDriverName);
    return driverName;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:21,代码来源:Db.java


示例7: getDriverType

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Translate the driver type for composing the connection url
 *
 * @return the driver string for the connection url
 */
public String getDriverType() {
    String type = "";
    switch (getDbType()) {
        case AS400:
            type = "as400";
            break;
        case PGSQL:
            type = "postgresql";
            break;
        case MSSQL:
            type = "sqlserver";
            break;
    }
    return type;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:21,代码来源:Db.java


示例8: main

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 *
 * @param args
 */
public static void main(String[] args) {
    String sysName = args[0];
    String userId = args[1];
    String password = args[2];
    String spoolFileName = args[3];
    int spoolNumber = Integer.parseInt(args[4]);
    String jobName = args[5];
    String jobUser = args[6];
    String jobNumber = args[7];

    try {
        AS400 as400 = AS400Factory.newAS400(sysName, userId, password);
        SpooledFilePageFetcher fetcher = new SpooledFilePageFetcher(as400, spoolFileName, spoolNumber, jobName, jobUser, jobNumber);
        System.out.print(fetcher.readAllPages());
        System.out.flush();
    } catch (AS400SecurityException | PropertyVetoException | ErrorCompletingRequestException | IOException | InterruptedException | RequestNotSupportedException ex) {
        LOG.log(Level.SEVERE, "Exception fetching spooled file", ex);
    }

}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:25,代码来源:SpooledFilePageFetcher.java


示例9: main

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 *
 * @param args
 */
public static void main(String[] args) {
    String sysName = args[0];
    String userId = args[1];
    String password = args[2];
    String spoolFileName = args[3];
    int spoolNumber = Integer.parseInt(args[4]);
    String jobName = args[5];
    String jobUser = args[6];
    String jobNumber = args[7];

    try {
        AS400 as400 = AS400Factory.newAS400(sysName, userId, password);
        SpooledFileFetcher fetcher = new SpooledFileFetcher(as400, spoolFileName, spoolNumber, jobName, jobUser, jobNumber);
        System.out.print(fetcher.fetchSpooledFile());
        System.out.flush();
    } catch (AS400SecurityException | PropertyVetoException | ErrorCompletingRequestException | IOException | InterruptedException | RequestNotSupportedException ex) {
        LOG.log(Level.SEVERE, "Exception fetching spooled file", ex);
    }

}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:25,代码来源:SpooledFileFetcher.java


示例10: newAS400

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Create a new AS400 object with the correct security type and signon
 * handler using our extenders to have the password at our disposal for use
 * with JTOpenLite classes.
 *
 * @param signon_security_type is this none or ssl?
 * @param signon_handler_type handler type for failed signons
 * @param systemName systemName
 * @param userId userId
 * @param password password
 * @return the new AS400 object
 */
protected static AS400 newAS400(SIGNON_SECURITY_TYPE signon_security_type, SIGNON_HANDLER_TYPE signon_handler_type, String systemName, String userId, String password) {
    AS400 as400
            = signon_security_type == SIGNON_SECURITY_TYPE.NONE
                    ? new AS400(systemName, userId, password)
                    : new SecureAS400(systemName, userId, password);
    switch (signon_handler_type) {
        case CUSTOM:
            as400.setSignonHandler(new SignonHandler());
            break;
        case NULL:
            as400.setSignonHandler(new NullSignonHandler());
            break;
        case BUILTIN:
            break;
    }
    return as400;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:30,代码来源:AS400Factory.java


示例11: getSpooledFileListerFromArgs

import com.ibm.as400.access.AS400; //导入依赖的package包/类
private SpooledFileLister getSpooledFileListerFromArgs(ArgArray argArray) throws PropertyVetoException, AS400SecurityException {
    SpooledFileLister splflister = null;
    AS400 a = getAs400();
    if (a == null) {
        try {
            setAs400(as400FromArgs(argArray));
        } catch (PropertyVetoException ex) {
            getLogger().log(Level.SEVERE, "Could not instance AS400 system from provided arguments in " + getNameAndDescription(), ex);
        }
    }
    if (a != null) {
        String spoolowner = argArray.nextMaybeQuotationTuplePopStringTrim();
        splflister = new SpooledFileLister(a);
        splflister.setUserFilter(spoolowner);
    }
    return splflister;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:18,代码来源:CmdSpoolFList.java


示例12: getSpooledFileFromArgs

import com.ibm.as400.access.AS400; //导入依赖的package包/类
private SpooledFile getSpooledFileFromArgs(ArgArray argArray) {
    SpooledFile splf = null;
    AS400 a = getAs400();
    if (a == null) {
        try {
            setAs400(as400FromArgs(argArray));
        } catch (PropertyVetoException ex) {
            getLogger().log(Level.SEVERE, "Could not instance AS400 system from provided arguments in " + getNameAndDescription(), ex);
        }
    }
    if (a != null) {
        String name = argArray.nextMaybeQuotationTuplePopStringTrim();
        int number = argArray.nextIntMaybeQuotationTuplePopString();
        String jobName = argArray.nextMaybeQuotationTuplePopStringTrim();
        String jobUser = argArray.nextMaybeQuotationTuplePopStringTrim();
        String jobNumber = argArray.nextMaybeQuotationTuplePopStringTrim();
        splf = new SpooledFile(a, name, number, jobName, jobUser, jobNumber);
    }
    return splf;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:21,代码来源:CmdSpoolF.java


示例13: getTextToWrite

import com.ibm.as400.access.AS400; //导入依赖的package包/类
private String getTextToWrite(AS400 as400, String writeableString) throws FileNotFoundException, IOException {
    String text = null;
    DataSink dsrc = getDataSrc();
    switch (dsrc.getType()) {
        case STD:
            text = writeableString;
            break;
        case FILE:
            File f = new File(dsrc.getName());
            FileReader fr = new FileReader(f);
            int length = new Long(f.length()).intValue();
            char[] in = new char[length];
            fr.read(in);
            text = new String(in);
            break;
        case TUPLE:
            text = getTuple(dsrc.getName()).getValue().toString();
            break;
    }
    return text;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:22,代码来源:CmdIFS.java


示例14: getSpooledFileOpenListFromArgs

import com.ibm.as400.access.AS400; //导入依赖的package包/类
private SpooledFileOpenList getSpooledFileOpenListFromArgs(ArgArray argArray) {
    SpooledFileOpenList splfol = null;
    AS400 a = getAs400();
    if (a == null) {
        try {
            setAs400(as400FromArgs(argArray));
        } catch (PropertyVetoException ex) {
            getLogger().log(Level.SEVERE, "Could not instance AS400 system from provided arguments in " + getNameAndDescription(), ex);
            setCommandResult(COMMANDRESULT.FAILURE);
        }
    }
    if (a != null) {
        splfol = new SpooledFileOpenList(a);
    }
    return splfol;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:17,代码来源:CmdSpoolFOpenList.java


示例15: testConnectTimeout

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Test
public void testConnectTimeout() throws Exception
{
   As400OriginDataSource ds = new As400OriginDataSource();
   ds.setProperty(As400DataSource.USERNAME, "username");
   ds.setProperty(As400DataSource.PASSWORD, "password");
   ds.setProperty(As400DataSource.HOSTNAME, "10.254.254.254");

   AS400 conn = null;

   ds.setProperty(As400DataSource.CONNECT_TIMEOUT, "1"); // set to one second
   long start = System.nanoTime();
   try {
      conn = ds.getConnection();
      fail("Data Source getConnection should not have had sufficient time to connect");
   } catch(DataSourceException de) {
      long end = System.nanoTime();
      assertEquals("connection.timedout", de.getMessage());
      assertTrue(SECONDS.convert((end - start), NANOSECONDS) < 2);
   } finally {
      if(conn != null) conn.resetAllServices();
   }
}
 
开发者ID:cfloersch,项目名称:xdbcp,代码行数:24,代码来源:As400OriginDataSourceTest.java


示例16: testAvailable

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Test
public void testAvailable() throws Exception
{
   As400OriginDataSource ds = new As400OriginDataSource();
   ds.setProperty(As400DataSource.USERNAME, "username");
   ds.setProperty(As400DataSource.PASSWORD, "password");
   ds.setProperty(As400DataSource.HOSTNAME, "unknown.man.cox.com");

   AS400 conn = null;
   try {
      conn = ds.getConnection();
   } catch(Exception e) {
      assertEquals("Should have received a connect failure", "connect.failure", e.getMessage());
      assertFalse("Datasource should not be available after conn failure", ds.isAvailable());
   } finally {
      if(conn != null) conn.resetAllServices();
   }

   ds.close();
}
 
开发者ID:cfloersch,项目名称:xdbcp,代码行数:21,代码来源:As400OriginDataSourceTest.java


示例17: testCreateDateAndLastAccessDate

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Test
public void testCreateDateAndLastAccessDate() throws Exception
{
   As400OriginDataSource origin = createOriginDataSource();
   As400PoolingDataSource ds = new As400PoolingDataSource(origin);
   try {
      Assert.assertTrue("Dates don't match", ds.getCreateDate().equals(ds.getLastAccessDate()));
      ThreadUtils.sleep(100); // java system clock only has resolution of 20ms
      AS400 conn = null;
      try {
         conn = ds.getConnection();
      } finally {
         if(conn != null) conn.resetAllServices();
      }
      assertFalse("Dates match", ds.getCreateDate().equals(ds.getLastAccessDate()));
      Assert.assertTrue("Dates wrong", ds.getCreateDate().before(ds.getLastAccessDate()));
   } finally {
      ds.close();
   }
}
 
开发者ID:cfloersch,项目名称:xdbcp,代码行数:21,代码来源:As400PoolingDataSourceTest.java


示例18: passwordIncorrect

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Override
public boolean passwordIncorrect(SignonEvent event) {
    boolean result = false;
    AS400 as400 = AS400.class.cast(event.getSource());
    try {
        result = pollForPassword(as400);
    } catch (IOException ex) {
        Logger.getLogger(SignonHandler.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:12,代码来源:SignonHandler.java


示例19: userIdUnknown

import com.ibm.as400.access.AS400; //导入依赖的package包/类
@Override
public boolean userIdUnknown(SignonEvent event) {
    boolean result = false;
    AS400 as400 = AS400.class.cast(event.getSource());
    try {
        result = pollForUserId(as400);
    } catch (IOException | PropertyVetoException ex) {
        Logger.getLogger(SignonHandler.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:12,代码来源:SignonHandler.java


示例20: connect

import com.ibm.as400.access.AS400; //导入依赖的package包/类
/**
 * Connect to the database passing an AS400 object
 *
 * @param as400
 * @param port jdbc port
 * @param database name of database
 * @param connectionProperties any desired connection properties
 * @return the connection
 * @throws ClassNotFoundException
 * @throws SQLException
 */
public Connection connect(AS400 as400, String port, String database, ConnectionProperties connectionProperties)
        throws ClassNotFoundException, SQLException {
    AS400JDBCDataSource asjdbcds = new AS400JDBCDataSource(as400);
    if (port != null) {
        asjdbcds.setPortNumber(Integer.parseInt(port));
    }
    if (database != null) {
        asjdbcds.setDatabaseName(database);
    }
    asjdbcds.setProperties(connectionProperties);
    setConnection(asjdbcds.getConnection());
    return getConnection();
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:25,代码来源:Db.java



注:本文中的com.ibm.as400.access.AS400类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApiCallback类代码示例发布时间:2022-05-22
下一篇:
Java DedicatedServer类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap