Skip to main content

Posts

Showing posts from 2014

feofus solutions java interview questions

Today I would like to share an interview experience with you. Any way let me start.              They conducted a 2 hours written exam which includes technical question as well as aptitude question. I am not bothered about the aptitude question :P from my point of view , one with high technical skill will elected regardless of evaluating their aptitude skills.                            Well.. now let’s consider the technical questions. They have 4 questions. Two of them related to java collection framework , one is from hashSet and another from hashmap. And the third one related to database queries . It is not that much challenging ; an average programmer can handle that very quickly . For that reason will explain all other questions except the last one.         Before I dive in to the explanation I would like to share my overall outcome or how I treated that event. All those question are very simple to me but for various reasons I can’t perform well in that interview. I am

a simple example for jdbc PreparedStatement

a simple example for PreparedStatement package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); //stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); String sql="select * fr

How to use SQL Exception Methods in java

The following code shows the use of some sqlexception method package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery("select stateId,

jdbc scrollable resultset methods

The following code illustrate how to limit the number of result in a result set and methods in scrollable result set go through it and may helpful in some way package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); stmt=conn.createStatement(ResultSet.TYPE_SCRO

Displaying data from JDBC select statement

package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; Statement stmt=null; ResultSet rs=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); rs=stmt.executeQuery("select * from tours"); display(rs);

how to connect mysql database in java using jdbc

The following code illustrate how to connect mysql database using jdbc . It is very simple go through it and nothing fancy in it!!! package basics.in.java.blogspot.in; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class Main { private static final String USERNAME="root"; private static final String PASSWORD=""; private static final String CONN_STRING="jdbc:mysql://localhost/basicsinjavablogspot"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.jdbc.Driver"); Connection conn=null; try { conn= DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD); System.out.println("database connection successful"); } catch (SQLException e) { System.err.println("something went wrong in database connection"); e.printStackTrace(); } finally{ if(conn!=null){ conn.close(

Find out the frequency of each word in a paragraph in java

import java.util.*; class wordFrequency{ public static void main(String args[]){ String paragraph= "ab bc ab bc abbbb bc ab cd ef bc bc "; String eachWord[]=paragraph.split(" "); ArrayList listEachWord = new ArrayList (Arrays.asList(eachWord)); LinkedHashMap numeach=new LinkedHashMap (); for(int i=0;i&lteachWord.length;i++){ numeach.put(eachWord[i],Collections.frequency(listEachWord,eachWord[i])); } System.out.println(numeach); }}

Java String functions Exercise

1.Write a program to arrange a given set of names in alphabetical order import java.util.Arrays; class namesInAlphabeticalOrder{ public static void main(String args[]){ String names[]={"Sudeep","Rethin","george","Anu"}; System.out.println("before Sorting"); for(int i=0;i<names.length;i++) System.out.println(i+":"+names[i]); System.out.println("After Sorting"); Arrays.sort(names); for(int i=0;i&ltnames.length;i++) System.out.println(i+":"+names[i]); } }  2.Write a program to display the number of words in a given sentence 3.Accept a line of text.find the reverse of each word and display the string class countWord{ public static void main(String args[]){ String s="sudeep cv always find a way to success"; String[] s1=new String[s.length()]; s1=s.split(" "); System.out.println("Number of words in s is:"+s1.length); for(int i=0;i<s1.length;i++){ Strin

Spring configuration using maven and eclipse a crash course

Spring configuration using maven and eclipse a crash course: Tools you need to get standard with: Eclipse /springtoolsute M2Eclipse 1.Create a new maven project(Artifactid:maven-archetype-webapp) 2.   We need 3 dependencies they are:      Spring-webmvc       Servlet-api      Jstl We actually don’t need this servlet-api and jstl because tomcat going to serve those for us. Following are the dependencies which we need to add in the pom.xml file:       <!-- Spring MVC framework -->     <dependency>         <groupId>org.springframework</groupId>         <artifactId>spring-webmvc</artifactId>         <version>3.1.2.RELEASE</version>     </dependency> <dependency>         <groupId>javax.servlet</groupId>         <artifactId>servlet-api</artifactId>         <version>2.5</version>                    <scope>provided</scope>     </dependency>     <!-- JSTL -->     <dependenc

Video Tutorials on spring and hibernate

I have been searching for a good video tutorials on spring and hibernate since last two months and I end up with this tutorial series : http://pluralsight.com/training/Courses#java http://pluralsight.com/training/Courses/TableOfContents/springmvc-intro http://pluralsight.com/training/Courses/TableOfContents/hibernate-introduction http://pluralsight.com/training/Courses/TableOfContents/spring-jpa-hibernate As a beginner these tutorial are very help full to me to get started with spring and hibernate . There are plenty of tutorials on php and asp out there . But Tutorials on spring and hibernate are very rare .These tutorials helps you to get started with spring and hibernate  but these are paid  tutorials . If you are not that much rich ; then you can download the stuff from some alternative sites but I am not encourage you to do so . Hope this will help you . Happy coding Basics-In-Java