我有这段代码:
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String Username2 = request.getParameter("Username2");
String Password2 = request.getParameter("Password2");
String ResetPassword = request.getParameter("ResetPassword");
try {
Class.forName("com.mysql.jdbc.Driver");
String st = "jdbc:mysql://localhost:3306/LoginAccount";
Connection conn = (Connection) DriverManager.getConnection(st, "root", "baljinder");
Statement sta = (Statement) conn.createStatement();
ResultSet rs = sta.executeQuery("SELECT * FROM Account where Username='" + Username2 + "' && Password ='" + Password2 + "' ;");
while (rs.next()) {
if (Username2.equals(rs.getString("Username")) && Password2.equals(rs.getString("Password"))) {
sta.executeUpdate("update Account set Password …Run Code Online (Sandbox Code Playgroud) 我想用 Mojarra 2.1
http://javaserverfaces.java.net/download.html
我的容器是Tomcat 7,我正在使用IceFaces 2.
我应该只包括如下API吗?
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
更新:我正在使用servlet 3.0.1,jsp 2.2.1,el 2.2也许它是冲突的:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.2</version>
<scope>provided</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我在工作流程中严重依赖git.但是,我不使用IDEA的集成,因为使用shell和别名总是更快.现在我注意到,使VCS支持的时候,有一个Compare with same repository,Compare with branch,Compare with ....
现在我想知道是否有可能合并一个diff文件(与所有<<<<<<<).即使启用VCS支持,IDEA似乎也不支持这一点.
有没有人知道是否可以(和如何)将diff文件与IDEA合并?
我试图在几个服务器上使用Powershell远程获取DLL的文件版本,并将服务器名称,DLL版本和DLL文件位置写入csv或html报告.问题是一些服务器是Win 2003和Win 2008.因此该文件可能位于例如C:\ Program Files\WinZip\WZCAB.DLL或C:\ Program Files(x86)\ WinZip\WZCAB.DLL中.该脚本将检查一个位置,如果它不存在,它将检查另一个,然后将其写出.谁能帮我吗?
只需几件事 - 这个脚本将用于访问2003年和2008年的200多台服务器或VM.2003年它需要Powershell 2.0和2008,它将及时启用远程处理.我想也许我需要利用WMI.我有两个其他脚本利用WMI获取补丁和重启时间.虽然我尝试了Ravikanth脚本(再次感谢你)并且在传递服务器的txt文件时出现以下错误 - 一个或多个计算机名称无效.如果您尝试传递Uri,请使用-ConnectionUri参数或传递Uri对象而不是字符串.因为我不会在每台服务器上启用远程处理,还有另一种方法吗?我修改了Ravikanth脚本(下面)并在本地尝试过,效果很好.当我远程尝试时,它没有.有什么想法吗?
$servers = "D:\scripts\winzip\servers.txt"
$x86Path = 'C:\Program Files (x86)\WinZip\WZCAB.DLL'
$x64Path = 'C:\Program Files\WinZip\WZCAB.DLL'
foreach ($computername in $servers){
if (Test-Path $x86Path) {
(Get-Item $x86Path | Select -ExpandProperty VersionInfo).FileVersion
} elseif (Test-Path $x64Path) {
(Get-Item $x64Path | Select -ExpandProperty VersionInfo).FileVersion
}
}
Run Code Online (Sandbox Code Playgroud) 示例---对于SQL,我们将SQL语句编写为String,然后执行
strsql = "Select * from international_table ";
Run Code Online (Sandbox Code Playgroud)
现在我们做什么,我们类似地执行这个声明
我想在java或c#
像这样
strjavacode = "String str = \" Masdfksdja \";System.out.Println(str); "
Run Code Online (Sandbox Code Playgroud)
之后会有一些如何执行此操作
我渴望做这样的事情,我不必多次声明变量和赋值或语句.
据我所知,在C编程语言中,数组是一个元素一个元素地存储在内存中的。(即,元素 0、元素 1、元素 2、...、元素 n)。我正在尝试使用以下代码查看:
unsigned char a[] = { '\1' , '\2', '\3' ,'\4' };
printf("%d\n", (int*) a);
Run Code Online (Sandbox Code Playgroud)
由于 unsigned char 是 1 个字节,整数是 4 个字节;我认为它必须打印值:
00000001 00000010 00000011 00000100 = 2^2 + 2^8 + 2^9 + 2^17 + 2^24 = 16909060
但是,当我运行这个程序时,它会为每次试验生成不同的结果。
我在这里缺少什么?
我有嵌套类的Java问题.
我的第一类结构看起来像这样:
public class TopClass {
public void mainMethod() {
// uses the different "method" methods from
// NestedClass-implementing nested classes
}
private interface NestedClass {
public void method();
}
private class NestedClass1 {
public void method() {
}
}
private class NestedClass2 {
public void method(){
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是现在我希望这些method()方法是静态的,因为它们应该是主要的.
如果不将它们放在静态类中,我就无法使它们成为静态,但这没有问题,我使这些类保持静态,它们应该是无论如何.
它现在看起来像这样:
public class TopClass {
public void mainMethod() {
// uses the different "method" methods from
// NestedClass-implementing nested classes
}
private static interface NestedClass { …Run Code Online (Sandbox Code Playgroud) 我正在尝试在C中构建一个内存分配器.用户首先要说明他想要使用多少内存,以及可以使用的最小内存块大小.
因此,举例来说,假设用户请求最小块大小为8B的1024B.这意味着可能的块大小将是1024,512,256,128,64,32,16和8.
为了跟踪空闲的内存块,我有一个结构指针数组.这些结构称为Header,该数组称为FreeList.我的意思是FreeList [0]将包含一个指向内存空间的指针,其中有一个内存块大小为8. FreeList [1]将包含一个指向内存空间的指针,其中有一块内存大小为16等等
typedef void * Addr;
struct Header
{
Addr next;
int order;
};
struct Header *FreeList[];
Run Code Online (Sandbox Code Playgroud)
我正在尝试为此空闲列表分配内存以使用以下代码:
FreeList = malloc(Order*sizeof(struct Header));
Run Code Online (Sandbox Code Playgroud)
其中Order是您可以拥有的不同块大小的数量.
我收到编译错误'FreeList'的类型不完整.
我不希望这些指针指向任何地方,我只想为数据分配空间.
我正在使用Java开发日期.我发现两个日期之间的区别.
public static void main(String[] args) {
final Date futDate = new GregorianCalendar(2012, 8, 15, 0, 0, 0).getTime();
final Date currentDate = new GregorianCalendar().getTime();
long diff = Math.round((futDate.getTime() - currentDate.getTime()) / 1000);
System.out.println(diff / 86400 + " days");
System.out.println((diff % 86400) / 3600 + " hrs");
System.out.println(((diff % 86400) % 3600) / 60 + " mins");
System.out.println((((diff % 86400) % 3600) % 60) % 60 + " secs");
}
Run Code Online (Sandbox Code Playgroud)
输出:
31 days
8 hrs
37 mins
30 secs
Run Code Online (Sandbox Code Playgroud)
即使日期差异小于一天,输出也超过31天.
我需要创建临时目录,但是当我尝试在临时目录中创建文件时,我总是被拒绝访问.
java.io.FileNotFoundException: C:\tmpDir7504230706415790917 (Access Denied)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
public static File createTempDir() throws IOException {
File temp = File.createTempFile("tmpDir", "", new File("C:/"));
temp.delete();
temp.mkdir();
return temp;
}
public File createFile(InputStream inputStream, File tmpDir ) {
File file = null;
if (tmpDir.isDirectory()) {
try {
file = new File(tmpDir.getAbsolutePath());
// write the inputStream to a FileOutputStream
OutputStream out = new FileOutputStream(file);
int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
out.write(bytes, 0, read);
}
inputStream.close();
out.flush(); …Run Code Online (Sandbox Code Playgroud)