forked from Sanjiv-K/Mphasis-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e61318e
commit 61d68e2
Showing
37 changed files
with
896 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
CREATE OR REPLACE PROCEDURE p1(no in number) | ||
CREATE OR REPLACE PROCEDURE p11 | ||
AS | ||
BEGIN | ||
dbms_output.put_line('Square of '||no|| ' is '||no*no); | ||
|
||
update product set product_name='Monitor' where product_id='P001'; | ||
commit; | ||
|
||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CREATE OR REPLACE PROCEDURE p11(pid in varchar2(10)) | ||
AS | ||
BEGIN | ||
|
||
update product set product_name='New Value' where product_id=pid; | ||
commit; | ||
|
||
END; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/.metadata/ | ||
/.recommenders/ |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import oracle.jdbc.driver.OracleDriver; | ||
|
||
public class OracleDB { | ||
|
||
public static void main(String[] args) { | ||
|
||
// 1. Load Driver class | ||
|
||
Connection con = null; | ||
|
||
|
||
try { | ||
|
||
|
||
Class.forName("oracle.jdbc.driver.OracleDriver"); | ||
// System.out.println("-- Driver class loded"); | ||
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:mphasis", "scott", "tiger"); | ||
// System.out.println("-- Connection Established with "+con); | ||
|
||
} catch (Exception e) { | ||
System.out.println("--- Failed due to " + e); | ||
}finally { | ||
try { | ||
con.close(); | ||
} catch (SQLException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JDBC-Driver"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Jdbc-App-1</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com; | ||
|
||
import com.product.dao.StoredProcedures; | ||
|
||
public class CallableStatementDemo { | ||
|
||
public static void main(String[] args) { | ||
|
||
StoredProcedures sp=new StoredProcedures(); | ||
sp.demo7(); | ||
|
||
System.out.println("--- Done "); | ||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com; | ||
|
||
import java.util.List; | ||
|
||
import com.product.dao.ProductDaoImpl; | ||
import com.product.model.Product; | ||
|
||
public class FindProduct { | ||
|
||
public static void main(String[] args) { | ||
|
||
ProductDaoImpl prodDao = new ProductDaoImpl(); | ||
|
||
Product p = prodDao.findProduct("P00001"); | ||
|
||
System.out.println(p.getProdId()); | ||
System.out.println(p.getProdName()); | ||
System.out.println(p.getPrice()); | ||
System.out.println("--------------------"); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com; | ||
|
||
import java.util.List; | ||
|
||
import com.product.dao.ProductDaoImpl; | ||
import com.product.model.Product; | ||
|
||
public class ListProducts { | ||
|
||
public static void main(String[] args) { | ||
|
||
Product prod=new Product(); | ||
prod.setProdId("P007"); | ||
prod.setProdName("Mobile"); | ||
prod.setPrice(4453); | ||
|
||
|
||
ProductDaoImpl prodDao=new ProductDaoImpl(); | ||
//prodDao.saveProduct_v1(prod); | ||
|
||
List<Product> prods= prodDao.listAll(); | ||
|
||
for(Product p:prods) { | ||
System.out.println(p.getProdId()); | ||
System.out.println(p.getProdName()); | ||
System.out.println(p.getPrice()); | ||
System.out.println("--------------------"); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com; | ||
|
||
import java.util.List; | ||
|
||
import com.product.dao.ProductDaoImpl; | ||
import com.product.model.Product; | ||
|
||
public class ListProducts_ResultSetTypes { | ||
|
||
public static void main(String[] args) { | ||
|
||
ProductDaoImpl prodDao = new ProductDaoImpl(); | ||
|
||
|
||
|
||
Product p = prodDao.findProduct_v2(); | ||
|
||
System.out.println(p.getProdId()); | ||
System.out.println(p.getProdName()); | ||
System.out.println(p.getPrice()); | ||
System.out.println("--------------------"); | ||
|
||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
JDBC/Jdbc-App-1/src/com/SaveProduct_PreparedStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com; | ||
|
||
import java.util.List; | ||
|
||
import com.product.dao.ProductDaoImpl; | ||
import com.product.model.Product; | ||
|
||
public class SaveProduct_PreparedStatement { | ||
|
||
public static void main(String[] args) { | ||
|
||
Product prod=new Product(); | ||
prod.setProdId("P007"); | ||
prod.setProdName("Mobile"); | ||
prod.setPrice(4453); | ||
|
||
|
||
ProductDaoImpl prodDao=new ProductDaoImpl(); | ||
prodDao.saveProduct_v1(prod); | ||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com; | ||
|
||
import java.util.List; | ||
|
||
import com.product.dao.ProductDaoImpl; | ||
import com.product.model.Product; | ||
|
||
public class SaveProduct_Statement { | ||
|
||
public static void main(String[] args) { | ||
|
||
Product prod=new Product(); | ||
prod.setProdId("P007"); | ||
prod.setProdName("Mobile"); | ||
prod.setPrice(4453); | ||
|
||
|
||
ProductDaoImpl prodDao=new ProductDaoImpl(); | ||
prodDao.saveProduct(prod); | ||
|
||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com; | ||
|
||
import com.product.dao.JdbcTransactions; | ||
|
||
public class TransactionTest { | ||
|
||
public static void main(String[] args) { | ||
|
||
JdbcTransactions jt=new JdbcTransactions(); | ||
jt.demo2(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.product.dao; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.SQLException; | ||
|
||
public class DbUtils { | ||
|
||
private DbUtils() { | ||
// TODO Auto-generated constructor stub | ||
} | ||
|
||
private static Connection con = null; | ||
|
||
public static Connection getConnection() { | ||
|
||
if (con == null) { | ||
try { | ||
Class.forName("oracle.jdbc.driver.OracleDriver"); | ||
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:mphasis", "scott", "tiger"); | ||
|
||
} catch (Exception e) { | ||
|
||
e.printStackTrace(); | ||
} | ||
} // end of if | ||
return con; | ||
}// get connection end | ||
|
||
|
||
public static void closeConnection() { | ||
|
||
if(con!=null) | ||
try { | ||
con.close(); | ||
} catch (SQLException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
|
||
|
||
} // closeConnection end | ||
|
||
} // class end |
Oops, something went wrong.