Oracle · oracle · Uncategorized

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 =============== alter user awb identified by awb; To use import tool go to the following… Continue reading Oracle Sql


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 is incorrectly specified Cause This arises if you have not set ORACLE_HOME and ORACLE_SID. Solution… Continue reading How to Fix ORA-12162 TNS:net service name is incorrectly specified Error in Oracle?

java · mysql

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 = != -1) { System.out.print((char) ch); } } catch (IOException anIOException) { System.out.println(anIOException); } } }

java · jdbc · mysql

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>… Continue reading SqlExecuter vs JDBC

java · jdbc · mysql

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 && { lastInsertedId = rskey.getInt(1); } return lastInsertedId; }