Q:

Error while connecting to database using spring framework

I get the error:
java.sql.SQLException: Invalid Oracle URL specified
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:428)
    at java.sql.DriverManager.getConnection(DriverManager.java:579)
    at java.sql.DriverManager.getConnection(DriverManager.java:190)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:120)
    at com.Templates.DBOperation.DBOperationBean.fetchName(DBOperationBean.java:34)
    at com.Templates.DBOperation.DBOperationClient.main(DBOperationClient.java:29)

Here is my code:
ApplicationContext.xml file:
<beans>
 <bean id = "drds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name = "driverClassName" value = "oracle.jdbc.driver.OracleDriver"/>
        <property name = "url" value = "jdbc:oracle:thin@localhost:1521:orcl"/>
        <property name = "username" value = "templates"/>
        <property name = "password" value = "templates"/>
    </bean>

    <bean id = "dob" class="com.Templates.DBOperation.DBOperationBean">
        <property name = "ds" ref = "drds"/>
    </bean>
</beans>

Bean class:
public class DBOperationBean implements DBOperation {

    //Bean Property
    DataSource ds;

    //Setter method to support injection
    public void setDs(DataSource ds) {
        this.ds = ds;
    }

    //implement bean methods
    @Override
    public String fetchName(String ename) {
        //To change body of generated methods, choose Tools | Templates.
        String name = null;
        try {
            //get one connection object from connection pool
            Connection con = ds.getConnection();
            //get emp name
            PreparedStatement pst = con.prepareStatement("select name from employee where empno = ?");
            int empno = 1;
            pst.setInt(1, empno);

            ResultSet rs = pst.executeQuery();

            if (rs.next()) {
                name = rs.getString("NAME");
            } else {
                name = "record not found";
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return name;
    }

    @Override
    public int fetchSalary(int empNo) {
        int sal = 0;

        try {

            Connection con = ds.getConnection();
            PreparedStatement pst = con.prepareStatement("select sal from employee where sal =?");
            pst.setInt(1, sal);
            ResultSet rs = pst.executeQuery();
            while(rs.next())
            {
                sal = rs.getInt("SAL");
            }
        } catch (Exception e) {
        }
        return sal;
    }
}

And client class:
public class DBOperationClient {
    public static void main(String[] args) {
        Resource res = new ClassPathResource("applicationContext.xml");

        //Activate bean factory container
        BeanFactory fac = new XmlBeanFactory(res);

        //get spring bean from container
        DBOperation beanObject = (DBOperation)fac.getBean("dob");

        //call bean methods
        System.out.println("Employee name is: " + beanObject.fetchName("NAME"));
        System.out.println("Employee salary is: " + beanObject.fetchSalary(1));
    }
}

I went through other similar questions on stackoverflow and modified the url which didn't work. The url looks alright but still I get the same error: Invalid Oracle URL specified

A:

You're missing a colon after "thin".
http://razorsql.com/docs/help_oracle.html
Try it like this: 
<beans>
 <bean id = "drds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name = "driverClassName" value = "oracle.jdbc.driver.OracleDriver"/>
        <property name = "url" value = "jdbc:oracle:thin:@localhost:1521:orcl"/>
        <property name = "username" value = "templates"/>
        <property name = "password" value = "templates"/>
    </bean>

    <bean id = "dob" class="com.Templates.DBOperation.DBOperationBean">
        <property name = "ds" ref = "drds"/>
    </bean>
</beans>

