我试图对我的ArrayList进行排序.
java.util.ArrayList arList= new java.util.ArrayList();
arList=getList();
java.util.Collections.sort(arList);
Run Code Online (Sandbox Code Playgroud)
我的getList()函数在这里
public ArrayList getList() throws Exception
{
ArrayList listItems = new ArrayList();
//Query executing here..............!
while (rs.next())
{
HashMap hashList = new HashMap();
hashList.put("name",rs.getString(1));
hashList.put("id",rs.getBigDecimal(2));
listItems.add(hashList);
}
return listItems;
}
Run Code Online (Sandbox Code Playgroud)
但我面临错误:java.lang.ClassCastException:java.util.HashMap无法强制转换为java.lang.Comparable
尝试使用以下代码编写excel文件
public static void main(String[] args)
{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Book Data");
Map<String, Object[]> data = new TreeMap<String, Object[]>();
data.put("1", new Object[] {"ID", "NAME", "LASTNAME"});
for(int i=2;i<100000;i++)
{
data.put(String.valueOf(i), new Object[] {i, "Name"+i, "LastName"+i});
}
Set<String> keyset = data.keySet();
int rownum = 0;
for (String key : keyset)
{
Row row = sheet.createRow(rownum++);
Object [] objArr = data.get(key);
int cellnum = 0;
for (Object obj : objArr)
{
Cell cell = row.createCell(cellnum++);
if(obj instanceof String) …Run Code Online (Sandbox Code Playgroud) 我试图xlsx使用Apache POI 将报告导出为格式化.以下是用于的代码.
public static void main(String[]args){
try{
XSSFWorkbook wb=new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("new sheet");
XSSFRow rowhead= sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("column1");
rowhead.createCell((short) 1).setCellValue("column2");
rowhead.createCell((short) 2).setCellValue("column3");
rowhead.createCell((short) 3).setCellValue("column4");
rowhead.createCell((short) 4).setCellValue("column5");
System.out.println("im here");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:...,....);
Statement st=con.createStatement();
System.out.println("im here1");
ResultSet rs=st.executeQuery("SELECT * FROM table3 ");
System.out.println("im here2");
int i=1;
while(rs.next()){
XSSFRow row= sheet.createRow((short)i);
row.createCell((short) 0).setCellValue(rs.getString("column1"));
row.createCell((short) 1).setCellValue(rs.getString("column2"));
row.createCell((short) 2).setCellValue(rs.getString("column3"));
row.createCell((short) 3).setCellValue(rs.getString("column4"));
row.createCell((short) 4).setCellValue(rs.getString("column5"));
i++;
}
FileOutputStream fileOut = new FileOutputStream(new File("E:/report.xlsx"));
wb.write(fileOut);
fileOut.close();
System.out.println("Your excel file has …Run Code Online (Sandbox Code Playgroud) 当按下 ESC 时,我试图调用一个函数使屏幕再次处于全屏模式。(也就是说,当按下 ESC 时,屏幕进入正常模式。我需要再次使其处于全屏模式)。识别出 ESC 单击事件再次调用全屏功能,例如
$(document).ready(function (){
var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange";
$(document).on(screen_change_events, function () {
if (!window.screenTop && !window.screenY) {
$("iframe")['webkitRequestFullScreen'](); // Identified that ESC is triggered.So need to make it again fullscreen mode
}else{
//alert("no")
}
});
});
Run Code Online (Sandbox Code Playgroud)
但出现以下错误。
Uncaught TypeError: $(...).webkitRequestFullScreen is not a function
Run Code Online (Sandbox Code Playgroud) 例如something:8000/something.jsp?param1=update¶m2=1000¶m3=SearchString%¶m4=3,在传递我的网址时,我收到以下错误:
Bad Request
Your browser sent a request that this server could not understand.
Run Code Online (Sandbox Code Playgroud)
我知道SearchString%我需要传递哪个作为参数,有问题.那么如何在URL中传递包含'%'的参数?
我限制我JTextFields只接受数字.我正在使用以下代码.
// my textboxes
t1=new JTextField(10);
t2=new JTextField(10);
t3=new JTextField(10);
// for the first one
t1.addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent e) {
char c = e.getKeyChar();
if (!((c >= '0') && (c <= '9') ||
(c == KeyEvent.VK_BACK_SPACE) ||
(c == KeyEvent.VK_DELETE))) {
getToolkit().beep();
e.consume();
}
}
});
Run Code Online (Sandbox Code Playgroud)
假设我有20个texboxes需要相同的验证检查.那么我们需要写这个代码20次吗?我可以写一个通用的方法来实现它吗?我是新来的Swing.
我对以下不匹配感到困惑.
Select table_name, Num_Rows
from all_tables
where OWNER = 'OWNER_NAME' and table_name='TABLE_NAME1';
Run Code Online (Sandbox Code Playgroud)
给了我一个结果401.
select count(*) from TABLE_NAME1
Run Code Online (Sandbox Code Playgroud)
给了我一个数200.在尝试时TABLE_NAME2,两者都返回相同的值.
这里发生了什么?
我试图在excel表中添加一些样式,我使用apache poi生成.这是代码,我试图在BOLD中创建第一行.
SXSSFWorkbook wb=new SXSSFWorkbook();
Sheet sheet = wb.createSheet("Excelx");
Row row= sheet.createRow((short)0);
row.createCell((short) 0).setCellValue("SRNum");
row.createCell((short) 1).setCellValue("Name");
CellStyle cs = wb.createCellStyle();
Font f = wb.createFont();
f.setFontHeightInPoints((short) 20);
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
cs.setFont(f);
row.setRowStyle(cs);
Run Code Online (Sandbox Code Playgroud)
但是,第一行仍未改为BOLD.
我试图使用以下查询从表中获取最后一条记录。
SELECT *
FROM TABLE1
WHERE ROWID IN (SELECT MAX (ROWID) FROM TABLE1);
Run Code Online (Sandbox Code Playgroud)
当我检查时ROWID,
值是 AAAZA5eAFAAA7AAAA
还有一些其他的价值MIN(ROWID)。
pseudocolumn这里如何对此进行评估?还提到了Oracle数据库不保证此类列的值是有效的rowid。因此,ROWID值在架构内不一定是唯一的吗?
根据文档: 数据库中的每一行都有一个地址。您可以通过查询伪列ROWID来检查行地址。该伪列的值是代表每行地址的字符串。这些字符串的数据类型为ROWID。您还可以创建包含具有ROWID数据类型的实际列的表和集群。Oracle数据库不保证此类列的值是有效的rowid。
我在尝试使用jasper生成excel报告时在WebSphere中获得以下异常.
ThreadMonitor W WSVR0605W: Thread "WebContainer : 0" (00000029) has been active for 647279 milliseconds and may be hung. There is/are 1 thread(s) in total in the server that may be hung.
Run Code Online (Sandbox Code Playgroud)
尝试将默认线程池大小从20增加到50,并将WebContainer池大小从50增加到150.不起作用.
任何解决方案.
我有一个ResultSet包含300K记录,我正在执行以下操作来迭代它(以及其他操作一旦收集).此过程大约需要2分钟才能完成.有没有办法优化它?
Map<String,Map<String,String>> internalMap = new HashMap<String,Map<String,String>>();
while (resultSet.next()) {
final Integer val1 = resultSet.getInt("val1");
final String val2 = resultSet.getString("val2");
final String val3 = resultSet.getString("val3");
final String val4 = resultSet.getString("val4");
final String type = resultSet.getString("type");
final String id = resultSet.getString("id");
addIntern(internalMap,val2,val1,val3,val4,type,id);
}
Run Code Online (Sandbox Code Playgroud)
以及addIntern上面引用的方法
private static void addIntern(Map<String,Map<String,String>> internalMap, String val2, Integer val1,
String val3,String val4,String type,String id) {
String key = id+"##"+val4;
if (internalMap.get(key) == null) {
internalMap.put(key, new HashMap<String,String>());
}
internalMap.get(key).put("val3", val3);
internalMap.get(key).put("val2", val2);
if("create".equals(type)){
internalMap.get(key).put("create", …Run Code Online (Sandbox Code Playgroud) 我试图通过基本身份验证获取 url。我设置了用户/密码,如下所示。同样的凭证在邮递员中工作。
String RELATIVE_IDENTITY_URL = "http://my_url/api/core/v3/people/email/abc@example.com";
RestTemplate restTemplate;
Credentials credentials;
//1. Set credentials
credentials = new UsernamePasswordCredentials("admin", "admin");
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials( AuthScope.ANY, credentials);
//2. Bind credentialsProvider to httpClient
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
httpClientBuilder.setDefaultCredentialsProvider(credsProvider);
CloseableHttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new
HttpComponentsClientHttpRequestFactory(httpClient);
//3. create restTemplate
restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
//4. restTemplate execute
String url = RELATIVE_IDENTITY_URL;
String xml = restTemplate.getForObject(url,String.class);
System.out.println("Done");
Run Code Online (Sandbox Code Playgroud)
我认为凭据设置不正确。这里有什么问题。?错误:
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 401 Unauthorized
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:620)
at …Run Code Online (Sandbox Code Playgroud) java ×7
apache-poi ×3
hashmap ×2
javascript ×2
oracle ×2
xlsx ×2
arraylist ×1
collections ×1
heap-memory ×1
html ×1
jdbc ×1
jquery ×1
jsp ×1
jtextfield ×1
keylistener ×1
sorting ×1
spring ×1
sql ×1
swing ×1
url ×1
websphere-7 ×1