Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Friday, April 28, 2017

Top 10 Oracle Certifications and How to Earn Them

Oracle Corporation is an international company that offers a variety of software and hardware solutions which are designed to streamline IT. Oracle offers many certifications in the area of Cloud, applications, Enterprise Management, Database, Foundations, Operating Systems, Training and Resources, Virtualization and much more. Over the years, Oracle has developed an extensive certification program. Today, it compromises 5 certification levels, covering 10 main categories and offers over 200 individual credentials.

Now the question arises why you should get Oracle Certifications. Answer is Credibility. Oracle Certifications gets you a competitive edge in comparison to other candidates with similar skills. In this competitive market adding an Oracle certification in your resume will increase the worth of your resume and will makes you more likely to win out over other candidates. Oracle Certifications are among the highest paying IT certifications. Moreover 97% of the Global Fortune 500 companies use Oracle software.  Thus, Oracle certifications make you a more desirable candidate. You can earn an Oracle Certifications by following given steps-

  • Explore the Certifications and select a certification to pursue based on that technology area in which you have interest.
  • Prepare for your certification exam by taking suitable training.
  • Register for your exam.
Given below are details of Oracle to 10 Certifications which you can pursue-

Oracle Database 11g: Administration I

By clearing this exam you gain the certification of Oracle Database 11g Administrator Certified Associate.  The duration of exam is 9o minutes and it consists of 7o multiple choice questions. The price of this exam is US$ 245 and minimum passing score is 66%.

Oracle Database 11g: Administration II

The duration of this exam is 120 minutes and it contains 78 multiple format questions. Minimum passing score in this exam is same as Oracle Database 11g: Administration I, that is, 66%.  By passing this exam you get the certification of Oracle Database 11g: Administration II. The price of this exam is US$ 245. 

Thursday, July 4, 2013

Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver

Exception in thread "main" java.lang.Exception: Error Initializing Context: oracle.jdbc.driver.OracleDriver
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:28)
at com.hewitt.appinv.sdc.db.TestJNDI.main(TestJNDI.java:14)
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.hewitt.appinv.sdc.db.LocalContextFactory.createLocalContext(LocalContextFactory.java:23)
... 1 more

If you see above error, Please add classes12.jar  in your applications classpath. Download it from here. classes12.jar  

Wednesday, February 6, 2013

Oracle Moves Past 2012 Woes


Oracle had a bumpy ride in 2012. The company lost an important patent lawsuit centered on Google's Android platform, which must have hurt. In the last half of the year, a series of unpatched security flaws were discovered, leading to many industry experts recommending users remove Java from their browsers entirely.

Oracle wasn't exactly proactive with its response to the security flaws, which allowed malware to escape the Java "sandbox." Instead, the company stuck to its questionable policy of releasing patches on a restrictive and immutable schedule. To many, it looked like the company was closing the remote blinds on the office windows and hoping the problem would go away.

Still Number One

In spite of these setbacks, Java remains the shining star in Oracle's portfolio. Java maintains its position as the most used coding language in the Pypl Popularity Language Index.

The outlook for Java developers is also promising. For the second year in a row, technology professional website Dice ranked Java and J2EE developers as the most sought-after professionals in the industry.

Bye-Bye Java 6, Hello 7

Okay, Java 7 has actually been out for some time now, but plenty of enterprises and consumers are still happy with Java 6. That's going to change in February 2013, when the last public patch for Java 6 comes out. After that, you're on your own as far as Java 6 security goes.

The first patch for Java 7 is due out during the summer of 2013, so you have plenty of time to roll over from Java 6 to the new version. Just don’t leave it too late; running an obsolete version of Java is an invitation for security breaches.


Java Closes One Door, Opens another


The last public security patch for Java 6 comes out February 19, 2013, marking an important turning point for Oracle. Java 6 was developed by Sun Microsystems, which Oracle bought out for a purported $7.4 billion in 2011. Java 7, in contrast, is the first edition of Java released by Oracle. With Java 6 retired, Oracle cuts the program’s last ties to its parent company.

To be totally fair, Java 6 enjoyed a longer life than previous editions. The final public patch was originally scheduled for July 2012, and then bumped back to November 2012. Despite these two reprieves, it looks like the end is finally in sight.

Life after Retirement  

The final security patch serves as a warning to consumers and businesses. Oracle continues to provide security patches to enterprises with support plans after a final public patch, but for those of us without support plans, it's time to consider switching to Java 7.

Sure, in theory you could continue to use Java 6, but without the safety net of security updates you're asking for trouble. Old and retired programs attract hackers and malware like hyenas circling an injured antelope. Both sets of scavengers know their preys' defenses are down.

If you’re looking to update to Java 7, do so before June 18, 2013. The date marks the first major patch for the new system. (Don't get me started on Oracle's ironclad update schedule; in my mind, patches should be released when they're needed, rather than on a fixed timetable. Emergency response teams and drug rehab centers offer protection and help when it's most needed. To my mind, security patches are the virtual equivalent).


Monday, December 24, 2012

Hibernate reverse engineering demo using Eclipse

Reverse Engineering: The most powerful feature of Hibernate Tools is a database reverse engineering tool that can generate domain model classes and Hibernate mapping files, annotated EJB3 entity beans, HTML documentation or even an entire JBoss Seam application in seconds. With the help of Eclipse you can do reverse Engineering. Lets see step by step to reverse-engineer database tables to generate hibernate POJO classes and mapping XML files using hibernate-tools (eclipse).

About the example: I am using My Eclipse 8.6 and MySQL. We will generate POJO classes and mapping XML files etc and latter run a test program. Please see the self explanatory screen shots below.

1. Create a New Java project
File -> New -> Java Project


Hibernate Examples - Native SQL Queries


You can also express queries in the native SQL dialect of your database. This is useful if you want to utilize database-specific features such as query hints or the CONNECT keyword in Oracle. It also provides a clean migration path from a direct SQL/JDBC based application to Hibernate.

Hibernate3 allows you to specify handwritten SQL, including stored procedures, for all create, update, delete, and load operations.

To know more, click here.

For example - we can have methods in DAO for executing Native SQL as shown below.

public List executeNativeQuery(String query) {
return getSession().createSQLQuery(query).list();
}

public List executeQuery(String query) {
return getSession().createQuery(query).list();
}

You can pass native SQL query as shown below -

List allObjects = empDao.executeNativeQuery("Select emp_id, emp_name  from EMPLOYEE");

Iterator it = allObjects.iterator();
while(it.hasNext())
{
Object row[] = (Object[])it.next();
for(Object eachRow : row) {
System.out.println(eachRow.toString());
}
}

Below are the known errors and exception -

1. Exception in thread "main" org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:79)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:104)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:393)
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:582)
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:508)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1821)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1723)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)


Solution - Above exception occurs if you pass * to fetch all columns in SQL like - "Select * from EMPLOYEE". this should be avoided.


Tuesday, November 6, 2012

MySQL - JDBC example for BLOB storage

A blob (binary large object) is a collection of binary data stored as a single entity in a database. Blobs can be used to store images, audio or other multimedia files. There are four variation of blob datatype -
  • TINYBLOB - Maximum length of 255 (2^8 - 1) characters i.e 25 bytes
  • BLOB - Maximum length of 65535 (2^16 - 1) characters i.e 64 KB
  • MEDIUMBLOB - Maximum length of 16777215 (2^24 - 1) characters i.e 16 MB
  • LONGBLOB - Maximum length of 4294967295 (2^32 - 1) characters i.e 4GB

About the example: We will create a table in mySql and see how to insert/reterive an image using JDBC.

First lets create a table in MySQL. Please see the syntax below, we have used MEDIUMBLOB as it would be sufficient for medium size object stotage. You can use any other as per your requirement. We have just 3 columns pic_id as a auto increment primary key, pic_name will hold the picture name and pic_file a blob which will store actual picture.

CREATE TABLE blobtest (
pic_id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (pic_id),
pic_name VARCHAR(100) NOT NULL,
pic_file MEDIUMBLOB
);


Thursday, October 4, 2012

Why PreparedStatement is used to prevents SQL Injection?

What is a SQL Injection?

In simple language SQL injection is injecting malicious sql code into the application's sql that may help attacker to retrieve sensitive information like user name / passwords etc OR it can also be used by hackers for login without authentication.

For example, We have a human resource management system, where in employee logs in and can view his / her sensitive information like attendance, salary etc. To log on to system every employee requires username and password. Now suppose below function is used to do authentication.

private boolean isAuthenticate(String userName, String password) {

Statement stat = connection.createStatement();

String query = "SELECT 1 FROM EMPLOYEE WHERE USER_NAME  = '"+userName+"'  AND PASSWORD = '"+password+"';";

ResultSet rset = stat.executeQuery(query);

if (rset.next()) {
return true;
}
else {
return false;
}
}


if the above query fetches result then allow the user to enter into the system else don't allow. You might think that the above process is correct but it's not like that, the above function has a serious flaw. let's see how.


Monday, February 15, 2010

MS SQL / Oracle : Get all Table / Column names from database

MS SQL

Get all table names of particular database
Query: select NAME from SYSOBJECTS where TYPE = 'U'

Get all column names of a table
Query: SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.Columns where TABLE_NAME = '<table name>'

Oracle

Get all table names of particular database
Query: select TABLE_NAME from DBA_TABLES where OWNER like '<database name>'

Get all column names of a table
Query: select COLUMN_NAME from ALL_TAB_COLS where TABLE_NAME ='<table name>'

Sunday, April 12, 2009

Java : JDBC Connection codes in Oracle and MS SQL

Oracle Connection



/* Here is complete code for OracleConnection.java */

import java.sql.*;

public class OracleConnection
{
public static void main(String[] args)
{
//connection
Connection con=null;
ResultSet rs=null;
Statement stmt=null;

try
{
Class.forName("oracle.jdbc.driver.OracleDriver"); //Step 1: Loading Drivers

con = DriverManager.getConnection("jdbc:oracle:thin:@10.10.10.10:8080:vas","username","password"); //Step 2: Making Connection

stmt = con.createStatement(); //Step 3: Creating JDBC Statement

String query = "Select * from EMPLOYEE";

rs = stmt.executeQuery(query); //Step 4: Execute the Ststement

while (rs.next()) //Step 5: Looping through the ResultSet
{
System.out.println(rs.getString(1)+""+rs.getString(2));
}

stmt.close(); //step 6: Close the Connection and Statement
con.close();
rs=null;
stmt=null;
con=null;
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}

MS SQL Connection




/* Here is complete code for MSSQLConnection.java */

import java.sql.*;

public class MSSQLConnection
{
public static void main(String[] args)
{
//connection
Connection con=null;
ResultSet rs=null;
Statement stmt=null;

try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //Step 1: Loading Drivers

con = DriverManager.getConnection("jdbc:sqlserver://10.10.10.10:8080;databaseName=DBNAME;user=scott;password=tiger"); //Step 2: Making Connection

stmt = con.createStatement(); //Step 3: Creating JDBC Statement

String query = "Select * from EMPLOYEE";

rs = stmt.executeQuery(query); //Step 4: Execute the Ststement

while (rs.next()) //Step 5: Looping through the ResultSet
{
System.out.println(rs.getString(1)+""+rs.getString(2));
}

stmt.close(); //step 6: Close the Connection and Statement
con.close();
rs=null;
stmt=null;
con=null;
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}