小编hap*_*ppy的帖子

结果集到 Excel 文件

有一个CSVWriter类用于将结果集写入 CSV 文件。

是否有任何类似的类用于将结果集输出写入EXCEL文件。?

编辑:我的结果集数据将是动态的,所以我只想将结果集数据转储到 Excel 文件中

编辑2:参考http://www.codereye.com/2009/09/converting-resultset-to-excel-table-in.html。它将数据导出到 Excel 表,但我需要传递每列的数据类型。我想删除该依赖关系,以便结果集中的任何内容都应该盲目地导出到 Excel 表。

java excel resultset

5
推荐指数
1
解决办法
3万
查看次数

在域模式Wildfly10中共享属性文件

在域模式下,我可以使用属性文件作为模块,但问题是如果文件中有任何修改,那么我需要为域中的所有从属文件执行此操作.我想集中文件,以便在某一点上我可以改变,它将反映在所有奴隶上.

我知道在domain.xml中我们可以配置全局级系统属性,但我有大约25个属性文件.

那么有没有办法集中文件?

myjar.jar
-->package
   --> class
-->properties
   -->xml files
Run Code Online (Sandbox Code Playgroud)

myjar.jar是一个存档的jar文件,用于获取xml文件

 URL url = Thread.currentThread().getContextClassLoader().getResource("./properties");

File queryFolder = new File(url.getFile());

for (File fileName : queryFolder.listFiles())  // null pointer exception
{
    if (fileName.getName().toUpperCase().endsWith("XML"))
    {   
            saxParser.parse(fileName, this);
     }
}
Run Code Online (Sandbox Code Playgroud)

这不起作用.

试过这个

如何列出JAR文件中的文件?

并面临下面链接中给出的相同问题

使用java nio Paths时未安装JBoss wildfly 8.x Provider"vfs"

URL w_url = mmyClass.class.getProtectionDomain().getCodeSource().getLocation();
            JarEntry w_ze = null;
            LOGGER.info("Jar******************" + w_url.toString());
            if (w_url.toString().endsWith(".jar")) 
            {
                try (JarInputStream jar = new JarInputStream(w_url.openStream())) 
                {
                    while ((w_ze = jar.getNextJarEntry()) != null)
                    {
                        LOGGER.info("Name *******" + w_ze.getName());
                    } …
Run Code Online (Sandbox Code Playgroud)

jboss jboss7.x wildfly wildfly-10

5
推荐指数
1
解决办法
141
查看次数

Wildfly 10中的默认slsb-strict-max-pool大小

在Wildfly 10服务器启动时,我们得到slsb-strict-max-pool为64

2017-08-24 12:51:09,164 INFO  [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 64 (per class), which is derived from thread worker pool sizing.
2017-08-24 12:51:09,166 INFO  [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 16 (per class), which is derived from the number of CPUs on this host.
Run Code Online (Sandbox Code Playgroud)

但是当我在下面为jboss-cli执行时,如下**max pool size is 20**图所示

/host=master/server=server-one/subsystem=ejb3/strict-max-bean-instance-pool=slsb-strict-max-pool/:read-resource(recursive=false)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

究竟Wildfly 10中ejb的默认最大池大小是多少?

ejb ejb-3.0 wildfly wildfly-10

5
推荐指数
1
解决办法
4029
查看次数

Wildfly 10中的内容类型问题

我在Wildfly 10上有一个Web应用程序,在Web应用程序目录中,我放置了一个zip文件,当用户点击超链接时我想要下载该文件.在我的UI上

片段

<div class="tyDiv" onclick="window.open('request.getContextPath() + "/downloads/Installer.exe")%>','_self')">
</div>
Run Code Online (Sandbox Code Playgroud)

它创建了正确的URL

"http://192.168.2.123:8080/comp/downloads/Installer.exe"


Content-Type:text/html;charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

这符合预期在JBoss6中有效.它下载exe文件但在Wildfly中它显示屏幕上的所有垃圾字符,因为它的内容类型是text/html

我尝试在standalone-full.xml中设置mime类型但是没有用.

 <mime-mappings>
    <mime-mapping name="css" value="text/css"/>
    <mime-mapping name="exe" value="application/octet-stream"/>
 </mime-mappings>
Run Code Online (Sandbox Code Playgroud)

mime-types wildfly wildfly-8 wildfly-10

5
推荐指数
1
解决办法
702
查看次数

JSF中的Web过滤器

我通过引用此链接实现Web过滤器

我的代码是

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>project_name</display-name>
    <welcome-file-list>
        <welcome-file>/project_name/faces/jsp/HomePage.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>resources.application</param-value>
    </context-param>

    <context-param>
        <param-name>org.richfaces.CONTROL_SKINNING</param-name>
        <param-value>enable</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.LoadScriptStrategy</param-name>
        <param-value>ALL</param-value>
    </context-param>
    <context-param>
        <param-name>org.richfaces.LoadStyleStrategy</param-name>
        <param-value>ALL</param-value>
    </context-param>
    <context-param>
        <param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
        <param-value>2764800</param-value>
    </context-param>
    <context-param>
        <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>org.ajax4jsf.handleViewExpiredOnClient</param-name>
        <param-value>true</param-value>
    </context-param>

    <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
        <init-param> …
Run Code Online (Sandbox Code Playgroud)

jsf java-ee servlet-filters

4
推荐指数
1
解决办法
1万
查看次数

单击按钮时,表单将被提交两次

我在下面调用了javascript函数

function formOnSubmit() {
  if (document.forms[0].ref_no.value == "") {
    if (document.forms[0].acc_code.value == "") {
      if (document.forms[0].vendor_code.value == "") {
        if (document.forms[0].acc_service_tax.value == "") {
          if (document.forms[0].acc_doc_name.value == "") {
            alert('Please enter atleast one attribute value');
            return false;
          }
        }
      }
    }
  } else {
    return true;
    document.forms[0].submit();
  }
}
Run Code Online (Sandbox Code Playgroud)

其中,ref_no,acc_code,vendor_code,acc_service_tax,acc_doc_name是文本框

问题是当我在ref_no texbox中输入内容时表单会被提交两次,而对于其余的文本框,表单会提交一次.

我想知道为什么在输入ref_no值时表单会被提交两次.

javascript

4
推荐指数
5
解决办法
2万
查看次数

通过java中的POST方法发送Xml字符串

我想通过POST方法将xml字符串传递给URL.

我试过下面的代码片段,但它没有返回任何内容

disableCertificateValidation();
String url = "https://..url";   //https

Properties sysProps = System.getProperties();
sysProps.put("proxySet", "true");
sysProps.put("proxyHost", "1.2.3.4");
sysProps.put("proxyPort", "80");

Authenticator authenticator = new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
        return (new PasswordAuthentication("userid",
                "password".toCharArray()));
    }
};
Authenticator.setDefault(authenticator);


 String xml = ---xml string;            


URL urll;
HttpURLConnection connection = null;
try {
    // Create connection
    urll = new URL(url);
    connection = (HttpURLConnection) urll.openConnection();
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type",
            "application/x-www-form-urlencoded");

    connection.setRequestProperty("Content-Length", ""
            + Integer.toString(xml.getBytes().length));
    connection.setRequestProperty("Content-Language", "en-US");

    connection.setUseCaches(false);
    connection.setDoInput(true);
    connection.setDoOutput(true);

    // Send request
    DataOutputStream wr = new DataOutputStream(connection
            .getOutputStream()); …
Run Code Online (Sandbox Code Playgroud)

java https post httpconnection

4
推荐指数
1
解决办法
4万
查看次数

命令提示符下的java.lang.NoClassDefFoundError

可能重复:
我可以从Eclipse创建的命令行程序运行吗?

当我尝试从命令提示符运行类文件时,我遇到异常,同样我在eclipse中运行,在那里我没有得到任何错误

试图从同一个文件夹运行

 Exception in thread "main" java.lang.NoClassDefFoundError: testClient (wrong nam
    e: com/mindcraft/queryExecutor/actionclass/testClient)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(Unknown Source)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$000(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: testClient.  Program will exit.
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
2万
查看次数

在 executeScript 处理器中读取外部属性

我在 nifi.variable.registry.properties 的 nifi.properties 中配置了一个外部属性文件。我想在 python 的 executeScript 处理器中读取这个属性。我用过 str(context.getProperty('URL'))但它不工作

apache-nifi

1
推荐指数
1
解决办法
911
查看次数

如何使用线程的id挂起线程?

我正在尝试的代码

public void killJob(String thread_id)throws RemoteException{   
Thread t1 = new Thread(a);   
    t1.suspend();   
}
Run Code Online (Sandbox Code Playgroud)

我们如何根据其ID暂停/暂停线程?不推荐使用Thread.suspend,必须有一些替代方法来实现这一点.我有线程ID我想暂停并杀死线程.

编辑:我用过这个.

AcQueryExecutor a=new AcQueryExecutor(thread_id_id);
Thread t1 = new Thread(a); 
t1.interrupt(); 
while (t1.isInterrupted()) { 
    try { 
       Thread.sleep(1000); 
    } catch (InterruptedException e) { 
       t1.interrupt(); 
       return; 
    } 
} 
Run Code Online (Sandbox Code Playgroud)

但我无法阻止这个话题.

java multithreading

0
推荐指数
1
解决办法
5477
查看次数

java中的唯一ID

可能重复:
在Java中生成UUID在Java中
创建GUID

我使用下面的代码片段来生成唯一的ID

String id = Long.toString(System.nanoTime());
Run Code Online (Sandbox Code Playgroud)

问题是它产生相同的id直到1分钟.

有没有其他方法来生成唯一的ID?

java

0
推荐指数
1
解决办法
1407
查看次数

SimpleDateFormat的结果不正确

我想转换Tue Jun 01 00:00:00 IST 11201-JUN-2012

我用了

 Calendar calendar = new GregorianCalendar(year, 6, Calendar.DAY_OF_MONTH); 
     Date maxDate=new Date();
     maxDate=calendar.getTime();  
     calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); 
      SimpleDateFormat s=new SimpleDateFormat("dd-mmm-yyyy");
       s.format(maxDate);
Run Code Online (Sandbox Code Playgroud)

但我明白了 30-000-0112

java datetime date simpledateformat

0
推荐指数
1
解决办法
1340
查看次数