我有一个小应用程序,我将用它来备份和恢复一个mysql数据库,编码备份如下,它工作正常,
....
String command = "mysqldump --host=" + dataBase.getHost() + " --user=" + dataBase.getUserName() + " --password=" + dataBase.getPassword() + " "
+ dataBase.getDatabaseName() + " -r " + dataBase.getBackupPath() + "/ofm_mnu_backup_" + bkDate + ".sql";
System.out.println(command);
Process p = null;
try {
Runtime runtime = Runtime.getRuntime();
p = runtime.exec(command);
int processComplete = p.waitFor();
if (processComplete == 0) {
System.out.println("Backup created successfully");
} else {
System.out.println("Could not create the backup");
}
....
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用以下代码恢复数据库时它无法正常工作,请帮助
........
String command = "mysqldump --host=" + …Run Code Online (Sandbox Code Playgroud) 我有一个在apache tomcat中运行的web应用程序,我使用"j_security_check"来保护这个应用程序.我的代码如下,
login.jsp的
<div id="loginForm">
<form id="loginfrm" method="post" action="j_security_check">
<table>
<tr>
<td>User Name</td>
<td><input type="text" id="name" name="j_username" size="20" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" id="phone" name="j_password" size="20" /></td>
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Login" id="submitButton"></td>
</tr>
</table>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
web.xml中
<web-app ...>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Example Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/success.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>
Run Code Online (Sandbox Code Playgroud)
错误页面,
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Login ERROR!</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
成功页面
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head> …Run Code Online (Sandbox Code Playgroud) 我在下面创建了一个swing应用程序,它在单击与特定任务相关的按钮时显示选项卡中的主要任务.我已经为每个选项卡添加了一个小的关闭按钮,当我点击与该选项卡相关的关闭按钮时,我需要关闭选项卡.

关闭按钮位于JPanel类中的类中,如下所示,
public class CloseTab extends JPanel {
JLabel title = new JLabel();
JButton closeButton = new JButton();
int tabIndex;
JTabbedPane tabbedPane = null;
public static int SELECTED_TAB_INDEX;
.
.
.
public static void setSELECTED_TAB_INDEX(int SELECTED_TAB_INDEX) {
CloseTab.SELECTED_TAB_INDEX = SELECTED_TAB_INDEX;
}
.
.
public void setCloseAction(ActionListener al) {
closeButton.addActionListener(al);
closeButton.setSize(10, 10);
closeButton.setBorder(new EmptyBorder(0, 0, 0, 0));
closeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/ofm/mnu/icons/delete.gif")));
}
public void setTabIndex(int index) {
this.tabIndex = index;
System.out.println(tabIndex);
}
public void init() {
add(title);
add(closeButton);
setOpaque(false);
setCloseAction(closeActoion);
}
ActionListener closeActoion …Run Code Online (Sandbox Code Playgroud) 我有一个方法,它执行一个简单的mysql插入,当我尝试回滚插入操作如下,一个错误,但它没有回滚错误,请帮助我,
public void addFamer(FamerDTO famer) throws Exception {
Connection con = JDBCConnectionPool.getInstance().checkOut();
con.setAutoCommit(false);
try {
String generalFamerDataSQL = "INSERT INTO famers(famer_code, name_wt_initials, full_name, gender, "
+ "nic_or_passport_no, sc_possition, phone_home, phone_mobile, phone_office) VALUES(?,?,?,?,?,?,?,?,?)";
PreparedStatement insertFamerPS = con.prepareStatement(generalFamerDataSQL, PreparedStatement.RETURN_GENERATED_KEYS);
insertFamerPS.setString(1, famer.getFamerCode());
insertFamerPS.setString(2, famer.getNameWithInitials());
insertFamerPS.setString(3, famer.getNameInFull());
insertFamerPS.setString(4, famer.getGender());
insertFamerPS.setString(5, famer.getNICorPassportNo());
insertFamerPS.setString(6, famer.getSocietyPosission());
insertFamerPS.setString(7, famer.getHomePhone());
insertFamerPS.setString(8, famer.getMobilePhone());
insertFamerPS.setString(9, famer.getOfficePhone());
insertFamerPS.execute();
String famerRelations = "INSERT INTO org_reg_blk_soc_fmr(org_id, region_id, famer_id, block_id, soc_id) "
+ "VALUES (?,?,?,?,?)";
PreparedStatement famerRelationsPS = con.prepareStatement(famerRelations);
famerRelationsPS.setInt(1, famer.getOrganization().getOrg_id());
famerRelationsPS.setInt(2, famer.getRegion().getRegion_id());
famerRelationsPS.setInt(3, famerID); …Run Code Online (Sandbox Code Playgroud) 我有以下PHP脚本显示网页中的验证码,验证码在我的本地apache服务器正常显示,但当我上传到网络托管服务器时,我得到一个错误,如下所述,请帮助
<?php
session_start();
$str = "";
$length = 0;
for ($i = 0; $i < 6; $i++) {
// these numbers represent ASCII table (small letters)
$str .= chr(rand(97, 122));
}
//md5 letters and saving them to session
$letters = md5($str);
$_SESSION['letters'] = $letters;
//determine width and height for our image and create it
$imgW = 150;
$imgH = 50;
$image = imagecreatetruecolor($imgW, $imgH);
//setup background color and border color
$backgr_col = imagecolorallocate($image, 238,239,239);
$border_col = imagecolorallocate($image, 208,208,208);
//let's choose …Run Code Online (Sandbox Code Playgroud) 我有一个JDialg来显示某个任务的进度.要显示和隐藏对话框,我有以下方法,
public class ProgressDisplayer extends javax.swing.JDialog {
......
public void s_show() {
this.setTitle("Month End Status");
setModal(true);
setResizable(false);
pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void s_hide() {
this.dispose();
}
...........
}
Run Code Online (Sandbox Code Playgroud)
当我尝试从线程中关闭这个JDialog框时,虽然它显示正常但我在调用pd.s_hide()方法时无法隐藏它.
...........
public void run() {
ProgressDisplayer pd = new ProgressDisplayer();
pd.s_show();
Thread.sleep(1000);
pd.s_hide();
}
.............
Run Code Online (Sandbox Code Playgroud)
请帮助我
java ×6
swing ×3
mysql ×2
captcha ×1
concurrency ×1
hibernate ×1
java-ee ×1
jdbc ×1
jdialog ×1
jtabbedpane ×1
jtable ×1
mysqldump ×1
php ×1
tomcat ×1
transactions ×1