Category Archives: database

Export and Import Oracle Database

this video created by Mohamed Yassin

Posted in oracle | Tagged , , | Leave a comment

ORA-01940: cannot drop a user that is currently connected solved

select sid, serial# from v$session where username = ‘AXF’; Alter user AXF account lock; alter system kill session ‘209,8029’; drop user AXF cascade;

Posted in database, oracle | Tagged , , , | Leave a comment

Oracle Sql

USING SQL PLUS or Any Oracle Tool Like “SQL Developer or TOAD” ============================================================== create user supplier2 identified by supplier2 grant connect,resource,dba to supplier2 unlock ====== alter user joe account unlock; alter user awb account unlock identified by awb; change password … Continue reading

Posted in Oracle, oracle, Uncategorized | Tagged , , | Leave a comment

How to Fix ORA-12162 TNS:net service name is incorrectly specified Error in Oracle?

sometimes  the oracle profile is not prepared correctly and this give so many errors and you should go direct to directory of SqlPlus to start DB /u01/app/oracle/product/11.2.0/dbhome_1/bin ./sqlplus sys/password as sysdba; the following error will arises ORA-12162 TNS:net service name … Continue reading

Posted in oracle | Tagged , , , , , , | 2 Comments

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) { … Continue reading

Posted in java, mysql | Comments Off on run linux command from java and reading result?

restarting mysql at linux

service mysql restart

Posted in linux, mysql | Comments Off on restarting mysql at linux

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 … Continue reading

Posted in java, jdbc, mysql | Comments Off on SqlExecuter vs JDBC

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; }

Posted in java, jdbc, mysql | Tagged , , , | Comments Off on how to get last insert id by java

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/’)

Posted in mysql, Uncategorized | Tagged | Leave a comment

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 … Continue reading

Posted in database, mysql | Leave a comment