Thursday, November 22, 2012
spring get bean from applicationcontext
Monday, October 22, 2012
How to add Oracle JDBC driver in your Maven local repository
http://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/
Which in short guides to do following steps in order to add your JDBC driver to your Maven local repository
Run below mvn command
mvn install:install-file -Dfile=D:\app\mkyong\product\11.2.0\dbhome_1\jdbc\lib\ojdbc6.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar
of course you will have to replace the path to OJDBC jar file with your machine's path. Maven will show you a build success message. After that you will have to add following dependency to your project's pom.xml
<!-- ORACLE database driver --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0</version> </dependency>
Friday, October 19, 2012
Enabling spring security in your spring application
package mypackage;
And you will have to add AuthenticationManager in your applicationContext-security.xml file as below
User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String name = user.getUsername(); //get logged in username
@RequestMapping(value="/login", method = RequestMethod.GET)
public String printWelcome(ModelMap model, Principal principal ) {
String name = principal.getName(); //get logged in username
model.addAttribute("username", name);
return "hello";
}
Saturday, October 13, 2012
Weblogic BEA-149265 , Caused By: java.lang.ClassNotFoundException: HttpServlet
I have configured weblogic 10.3.3 server in eclipse and the application had no errors. It was running from inside eclipse like a charm.
Tuesday, September 11, 2012
Spring MVC from getting started to advance level
A very good introductory article of Spring MVC
http://blog.springsource.com/2011/01/04/green-beans-getting-started-with-spring-mvc/
Spring showcase
http://blog.springsource.org/2010/07/22/spring-mvc-3-showcase/
Thursday, August 30, 2012
Common mistakes done in applications which can give a hacker full knowledge of your database
Its a bad practice to throw the whole exception message on the client console , if the exception is a jdbc exception throwed because of an error in update, any error in trigger execution e.t.c the raw exception stack trace has a lot of information about the tables in database fields in it and business rules implenented which caused this exception. This is a lot for a hacker he can easily build a knowledge base based on these exceptions, validations and business rules implemented in your database, infact your whole database can be open to him.
Its therefor a bad practice to let the presentation layer see the raw jdbc exception stack trace instead application developers should try to develop the wrapper exceptions and should try to show only relevent exception data on presentation layer.
Note : "I recently had a chance to work with a very good consultant from Mcafee, he told me that this is one of the main reasons hackers can hack the most secured applications easily once they hv access to the application they try different operations to cause the exceptions and build their knowledge by looking into the different exception". This was a very good informative session where I learnt a lot I will be writing more blogs on it so keep your fingers crossed and wait for some more good blog posts: ).
Saturday, August 4, 2012
java.sql.SQLSyntaxErrorException: ORA-01722: invalid number
One possible reason for java.sql.SQLSyntaxErrorException: ORA-01722: invalid number and it's solution
Below is the query I was trying to execute
select * from a_table where bi_num= 60