import java.net.URL;
import java.net.URLConnection;
import java.sql.*;
public class searchlink{
public static void main(String args[]) throws Exception {
//String link="http://hosted.ap.org";
Connection con=null;
Statement stmt=null;
Statement stmtR=null;
if(con==null){
SQLConnection.setURL("jdbc:sqlserver://192.168.2.53\\SQL2005;user=sa;password=365media;DatabaseName=LN_ADWEEK");
con=SQLConnection.getNewConnection();
stmt=con.createStatement();
stmtR=con.createStatement();
}
ResultSet rs;
rs=stmt.executeQuery("select url from urls where url='http://www.topix.com/rty/elyria-oh'");
while(rs.next()){
String mem=rs.getString(1);
System.out.println("Result is "+mem);}
}
}
Run Code Online (Sandbox Code Playgroud)
如果查询返回一行,上面的程序将打印输出.如果查询未返回任何内容,程序将停止而不打印任何内容.
而不是在没有打印任何东西的情况下停止它,我希望程序识别出查询没有返回任何内容并打印输出,如下所示"SQL查询执行后没有返回任何内容".
如何识别使用某些方法或变量来执行查询而不返回任何行?
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFCell;
import java.io.FileInputStream;
import java.lang.Iterable;
public class ReadExcel {
public static String fileToBeRead = "C:/Documents and Settings/Developer/Desktop/Anand exmps/Anand.xls";
public static void main(String argv[]) {
try {
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(fileToBeRead));
HSSFSheet sheet = workbook.getSheetAt(0);
//HSSFRow row = sheet.getRow(0);
//HSSFCell cell = row.getCell((short) 0);
for (Row row : sheet) {
for (Cell cell : row) {
System.out.println("THE TOP LEFT CELL–> "+ cell.getRichStringCellValue());
}
}
} catch (Exception e) {
System.out.println("!! Bang !! …Run Code Online (Sandbox Code Playgroud) 我编写了一个servlet java程序.
在执行程序的一个特定循环期间,我需要在JSP表单中显示一个gif文件,指示进程正在进行.
我不知道在循环中实现相同的内容.
请告知如何完成相同的操作,以便在JSP表单中显示gif文件,如果您可以为了处理显示而建议任何.gif文件,那将非常有用.我是java的初学者.
提前致谢
String date = new java.text.SimpleDateFormat("MM-dd-yyyy").format(new java.util.date());
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk", "/home/media/Desktop/FTP Upload/+date+"_RB.zip"", "/fileserver/filesbackup/Emac/+date+"_RB.zip"");
Run Code Online (Sandbox Code Playgroud)
uploadfile是将文件10-20-2010_RB.zip上传到服务器位置的功能.
但是因为我的路径中有字符串"date",所以很少出现非法表达式错误.
如果我尝试如下相同,该程序工作正常.
upload.uploadfile("192.168.0.210", "muruganp", "vm4snk", "/home/media/Desktop/FTP Upload/20-10-2010_RB.zip", "/fileserver/filesbackup/Emac/20-10-2010_RB.zip");
Run Code Online (Sandbox Code Playgroud)
出于某些原因,我强迫在文件路径中插入字符串.我怎样才能达到最终结果?好心提醒.
我的java程序将zip文件从我的系统上传到FTP服务器.uploadfile()是一个包含上传代码的函数.
uploadfile( "192.168.0.210", "muruganp", "vm4snk", "/首页/管理/ GATE521/LN_RB_Semivalid2junk /输出/" +日期+ "_ RB1.zip", "/文件服务器/ filesbackup/EMAC /" +日期+"_ RB1 .压缩");
public static boolean uploadfile(String server, String username,
String Password, String source_file_path, String dest_dir) {
FTPClient ftp = new FTPClient();
try {
int reply;
ftp.connect(server);
ftp.login(username, Password);
System.out.println("Connected to " + server + ".");
System.out.print(ftp.getReplyString());
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
return false;
}
System.out.println("FTP server connected.");
InputStream input = new FileInputStream(source_file_path);
ftp.storeFile(dest_dir, input);
System.out.println(ftp.getReplyString());
input.close();
ftp.logout(); …Run Code Online (Sandbox Code Playgroud) 我在Weblogic服务器中部署并运行了Java EE Web应用程序.
如果我想设置像这样的最小和最大参数,Xms100m Xmx500m,我应该在哪里更改它?
无论是在Weblogic 10.0MP服务器(如果是,在哪里),还是在IDE中构建应用程序?
An error occurred at line: 9 in the jsp file: /Test1.jsp
The method addURL(String, String) is undefined for the type SearchLink
6:
7: if(url1!=null && url1.trim().length()!=0){
8: myfirst.SearchLink p=new myfirst.SearchLink();
9: String result=p.addURL(url1,source1);
10: out.println(result);
11: System.out.println(result);
12: }else{
Run Code Online (Sandbox Code Playgroud)
如果您需要任何进一步的细节来回答错误原因,请告诉我.提前致谢
完整的jsp编码如下.
<%@ page import="myfirst.*" %>
<%
String url1=request.getParameter("url");
String source1=request.getParameter("source");
if(url1!=null && url1.trim().length()!=0){
myfirst.SearchLink p=new myfirst.SearchLink();
String result=p.addURL(url1,source1);
out.println(result);
System.out.println(result);
}else{
System.out.println("Not a valid url");
out.println("Not a valid url");
}
%>
Run Code Online (Sandbox Code Playgroud)
这是我的Java代码,名为SearchLink,我也编译了这个版本..
package myfirst;
import java.net.URL;
import java.net.URLConnection;
import java.sql.*; …Run Code Online (Sandbox Code Playgroud) import java.lang.Process;
import java.io.*;
import java.io.InputStream;
import java.io.IOException;
public class prgms{
public static void main(String[] args) {
try {
// Execute a command without arguments
String command = "java JavaSimpleDateFormatExample";
Process child = Runtime.getRuntime().exec(command);
// Execute a command with an argument
// command = "java JavaStringBufferAppendExample";
//child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
process((char)c);
}
in.close();
}
}
Run Code Online (Sandbox Code Playgroud)
我已经修改过这种方式......但是发生以下错误,
prgms.java:17: cannot find symbol
symbol : …Run Code Online (Sandbox Code Playgroud) 请考虑将下面代码中的URL分配给字符串
String link = "http://www.topix.com/rss/city/ellensburg-wa";
Run Code Online (Sandbox Code Playgroud)
我应该如何使用下面代码中的字符串而不是URL本身.
注意:我是java的初学者
stmt.executeQuery("select url from urls where url='http://www.topix.com/rss/city/ellensburg-wa'");
stmtR.executeUpdate("insert into urls values(21211,'http://www.topix.com/rss/city/ellensburg-wa','source',1,0)"
Run Code Online (Sandbox Code Playgroud) 我编写了一个名为Automate.java的java程序,其中将执行另一个名为newsmail的java程序.
我在这里遇到的问题是,Automate.java位于桌面位置(应该只在桌面上由于一些要求)并且newsmail在/home/Admin/GATE521/LN_RB这个位置.
在下面的代码之前必须做什么,以便命令提示符自动转到所需的文件夹并执行程序.
String command = "java newsmail";
Process child = Runtime.getRuntime().exec(command);
Run Code Online (Sandbox Code Playgroud) There is list
Awhich contains numbers in ascending order.Similarly a list
Bwhich also contains numbers in ascending order.The result should be list
Cwhich contains numbers fromAwhich are not inB.
My Solution:
I iterated through A and checked for the number in B using .contains() and added the required elements in C.
I was told using .contains() is higher order of complexity O(n).
Does anyone have a better solution?
我有一个在 node v6.12.0 中运行的 node js 项目,我需要将项目更新到 node v12.18。
这些是 package.json 中标记到项目的一些依赖项:
{
"hapi": "^8.8.0"
"joi": "^6.4.1"
"mocha": "^2.4.5"
"ioredis": "^2.4.0"
}
Run Code Online (Sandbox Code Playgroud)
想知道我应该执行哪些步骤才能使此升级成为可能!
如果我升级到 node v12,代码功能会中断吗?它是否向后兼容节点 v6?所有这些Promise.then(function())仍然可以在 node v12 中工作吗?