473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How Connect MS-SQL in java

6
Hi

I write a simple program to connect MS-SQL in java. But it not work fine.

So i want the exact code to connect MS-SQL with java.


Thanks
Bharathi..
Jul 30 '07 #1
8 2908
madhoriya22
252 100+
Hi

I write a simple program to connect MS-SQL in java. But it not work fine.

So i want the exact code to connect MS-SQL with java.


Thanks
Bharathi..
Hi,
Plz send the code whatever u hav written

Thanks and regards,
madhoriya
Jul 30 '07 #2
r035198x
13,262 8TB
Hi

I write a simple program to connect MS-SQL in java. But it not work fine.

So i want the exact code to connect MS-SQL with java.


Thanks
Bharathi..
What error messages do you get?
Jul 30 '07 #3
kanmbk
6
Hi madhoriya,

This is the code that i have written,

Expand|Select|Wrap|Line Numbers
  1.  <%@page language="java"%>
  2. <%@page import="java.io.*"%>
  3. <%@page import="java.lang.*"%>
  4. <%@page import="java.util.*"%>
  5. <%@page import="java.sql.*"%>
  6. <%
  7. String recid="HDR";
  8. String subid="S002";
  9. String file_id="X234";
  10. String trandate="2007/02/14";
  11. String prod="PROD";
  12. String filler="Yes";
  13.  
  14.     try
  15.      {
  16.         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
  17.         Connection C = DriverManager.getConnection("jdbc:microsoft:sqlserver://PEOPLET3:1433;DatabaseName=fox;SelectMethod=Cursor");
  18.         Statement st = C.createStatement();
  19.         st.executeUpdate("INSERT INTO `PDE_HDR_TBL` (`record_id` , `submitter_id` , `file_id` , `transaction_date` , `prod_cert_test_indicator` , `filler` )VALUES('"+ recid +"' , '"+ subid +"' , '"+ file_id +"' , '"+ trandate +"' , '"+ prod +"' , '"+ filler +"')");
  20.         out.println("inserted");
  21.      }
  22.     catch(Exception e)
  23.     {
  24.     out.println("Exception is :"+e);
  25.     }
  26. %>

Thanks and regards,
Bharathi
Jul 30 '07 #4
sicarie
4,677 Expert Mod 4TB
What's the error/problem you are having?

You are not passing it login credentials (unless you're passing it some really funky login/pw), is your db set up to allow this?
Jul 30 '07 #5
madhoriya22
252 100+
Hi madhoriya,

This is the code that i have written,

Expand|Select|Wrap|Line Numbers
  1.  <%@page language="java"%>
  2. <%@page import="java.io.*"%>
  3. <%@page import="java.lang.*"%>
  4. <%@page import="java.util.*"%>
  5. <%@page import="java.sql.*"%>
  6. <%
  7. String recid="HDR";
  8. String subid="S002";
  9. String file_id="X234";
  10. String trandate="2007/02/14";
  11. String prod="PROD";
  12. String filler="Yes";
  13.  
  14.     try
  15.      {
  16.         Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
  17.         Connection C = DriverManager.getConnection("jdbc:microsoft:sqlserver://PEOPLET3:1433;DatabaseName=fox;SelectMethod=Cursor");
  18.         Statement st = C.createStatement();
  19.         st.executeUpdate("INSERT INTO `PDE_HDR_TBL` (`record_id` , `submitter_id` , `file_id` , `transaction_date` , `prod_cert_test_indicator` , `filler` )VALUES('"+ recid +"' , '"+ subid +"' , '"+ file_id +"' , '"+ trandate +"' , '"+ prod +"' , '"+ filler +"')");
  20.         out.println("inserted");
  21.      }
  22.     catch(Exception e)
  23.     {
  24.     out.println("Exception is :"+e);
  25.     }
  26. %>

Thanks and regards,
Bharathi
Hi,
What errors u r getting? I hope there vil be lot of error?

Thanks and regards,
madhoriya
Jul 31 '07 #6
kanmbk
6
Hi madhoriya,

Actually i got the following error

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

Plz help me..


Thanks..
Bharathi.
Jul 31 '07 #7
praveen2gupta
201 100+
Hi

Your are missing driver of sql-server. Go to WEB-INF Then classes folder. now copy and paste sql server driver here.
Code is correct.
Jul 31 '07 #8
madhoriya22
252 100+
Hi madhoriya,

Actually i got the following error

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

Plz help me..


Thanks..
Bharathi.
Hi,
Here is the right syntax for getConnection method :----
Expand|Select|Wrap|Line Numbers
  1. Connection conn = DriverManager.getConnection("URL","UserName","Password");
  2.  
Make sure u r providing these data correctly. Here URL is the location where ur database server is residing, and rest two variables u can understand.
The error which u r getting is due to wrong socket u r providing, so check it again.

thanks and regards,
madhoriya
Jul 31 '07 #9

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

Similar topics

3
by: Bill | last post by:
When vb6 Winsock.RemoteHost is set to "127.0.0.1", c# socket listener cannot hear connect request (my old vb6 winsock listener could hear it...). Why doesn't this work, and is there a work...
1
by: Amadelle | last post by:
Hi all, I am so desparately in need of some guidance! After two days of struggling I still can't connect to the Active Directory server. I have used so many different ways and so many different...
0
by: christopher keller | last post by:
Hello, Using MS Access 97, SR2 mit MDAC 2.7 / 2.8 English/Deutsch we get the old problem of 'object not found' in DB2 Connect Version 8. ( From MS KB Q129814: "When you try to attach a DB2...
2
by: Grey | last post by:
I want to know that do I need to install MS Access in the machine in order to use ASP.NET connecting to MS Access because I got error when connect to DB
1
by: http://www.visual-basic-data-mining.net/forum | last post by:
Hi, I am new here. I am facing a problem that I can't connect to MS Access with my Web application written in VB.Net. It gives me this kind of error: The Microsoft Jet database engine cannot...
0
by: Parvez | last post by:
HI How to connect MS ACCESS in Netwaork base VB6.0 Programme from server I AM DEVLOPING A EMPLOYE ATTANEDENS RECORD PROJECT IN THIS I AM USING VB6.0 AND MS ACCESS AND WINDOEW XP IN MY PROJECT...
3
by: venkatesh | last post by:
hai to everybody I need to know how to connect database ms access or oracle with c or c++? please if u know tell I am interested in doing project with c thanks in advance....
3
by: ayyappa | last post by:
Hi All, I am working on Informatica Designer using MS Access. Here, i have successfully accessed the data thru ODBC connection. After creating session in Workflow Manager in Informatica, it has...
2
by: ublow56 | last post by:
I am trying to create an ASP application using javascript. I found may ways to connect to Ms Access using VBScript, but I can't find any for the Javascript... Can someone help me??? I just need...
1
by: chelluchittibabu | last post by:
hi, pls tell me if you know regarding ms exchange server 2007. In my system i am using windows 2003. what i want is 1. how to connect ms exchange server 2007 from .net 2. how to get data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.