By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,796 Members | 1,344 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,796 IT Pros & Developers. It's quick & easy.

SQL SERVER 2005 connection in java

P: 2
I am using following code and am using sqljdbc.jar file in lib folder of my project . but getting SQL Exception & Null pointer Exception,what is the reason? please Help me

Expand|Select|Wrap|Line Numbers
  1. DBConnectivity.java
  2.  
  3. try{ Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver);
  4. connection =DriverManager.getConnection("jdbc:sq lserver://localhost:8089;databaseName=bill;integratedSecu rity=true;");} 
  5.  
,
Expand|Select|Wrap|Line Numbers
  1. NewFile.jsp
  2. <%
  3. Connection con=DBConnectivity.getCon();
  4. Statement st=con.createStatement();
  5. String sql="select * from emp";
  6. ResultSet rs=st.executeQuery(sql);
  7. %>
  8.  
,
Expand|Select|Wrap|Line Numbers
  1.  Error Messages
  2.  1)java.lang.NullPointerException
  3.  2)com.microsoft.sqlserver.jdbc.SQLServerException: 
  4.  
Apr 26 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.