run linux command from java and reading result?

import java.*;
class Test {

public static void main(String[] args) {
int ch;
try {
Process myProcess = Runtime.getRuntime().exec(“ls -al”);
InputStreamReader myIStreamReader = new InputStreamReader(myProcess.getInputStream());
while ((ch = myIStreamReader.read()) != -1) {
System.out.print((char) ch);
}
} catch (IOException anIOException) {
System.out.println(anIOException);
}
}
}

SqlExecuter vs JDBC

public class CmdExec {

	public static void main(String argv[]) {
	           executeSql();
	  
	}
	private static void executeSql() {
	    final class SqlExecuter extends SQLExec {
	        public SqlExecuter() {
	            Project project = new Project();
	            project.init();
	            setProject(project);
	           // setTaskType("sql");
	            setTaskName("sql");
	        }
	    }

	    SqlExecuter executer = new SqlExecuter();
	    executer.setSrc(new File("/home/admin/Obama/scripfile.sql"));
	    executer.setDriver("com.mysql.jdbc.Driver");
	    executer.setPassword("root");
	    executer.setUserid("root");
	    executer.setUrl("jdbc:mysql://localhost:3306/Central_Share");
	    executer.execute();
	}
	
	}
//add dependency 
 <dependency>
        <groupId>izpack</groupId>
        <artifactId>izpack-standalone-compiler</artifactId>
        <version>3.7.2</version>
      </dependency>

how to get last insert id by java

	public static int getLastInsertID(Connection conn, String statment)throws SQLException {
		int lastInsertedId = -1;
		PreparedStatement ps = conn.prepareStatement(statment,PreparedStatement.RETURN_GENERATED_KEYS);
		ps.executeUpdate();

		ResultSet rskey = ps.getGeneratedKeys();
		if (rskey != null && rskey.next()) {
			lastInsertedId = rskey.getInt(1);
		}
		return lastInsertedId;
	}

How to find and replace in mysql

To find a string in a certain field and replace it with another string:

update [table_name] set [field_name] = replace([field_name],'[string_to_find]’,'[string_to_replace]’);

 

update `wp_posts` set `post_content` = replace(`post_content`,'http://localhost/elrashd/holding/','http://elrashad.promolinks.com/')

unknown-table-engine-innodb

http://www.osterman.com/wordpress/2007/12/23/unknown-table-engine-innodb

 

I was getting the error “ERROR 1286 (42000): Unknown table engine ‘InnoDB’” when trying to create/alter tables with the InnoDB engine. You can check for this warning by issuing the create or alter statements and then running

show warnings;

in the same mysql client session.

Check if you have InnoDB support enabled:

mysql> show variables like ‘have_innodb’;
+—————+———-+
| Variable_name | Value    |
+—————+———-+
| have_innodb   | DISABLED |
+—————+———-+

The problem is that InnoDB is not enabled by default in Debian distributions of my.cnf.  To enable it, simply comment the following lines under the [mysqld] section.

#skip-innodb