Connection String SQL SERVER 2000
Hi everybody:
I have a problem:
I want to connect to Sql Server 2000 from Java Server Pages but I can not do it.
In Active Server Pages I connect using:
"Provider=SQLOLEDB;Data Source=" SERVIDOR";Initial Catalog=IntranetHipohard;User id=sa;Password="
I would like that somebody write me by email.
This string not is valid for Java Server Pages.
How can I do it?
Thank you very much and sorry my language.
Well, it entirely depends on the JDBC driver you are using. If you are using Microsoft's driver currently in beta 2 (http://www.microsoft.com/sql), you use the following:
Driver Name
com.microsoft.jdbc.sqlserver.SQLServerDriver
Connection URL
jdbc:microsoft:sqlserver://<HOST>:1433;DatabaseName=<DATABASE>;User=<USER>;Password=<PASSWORD>
Where <HOST> is the IP or hostname of the machine running SQL Server 2000, and <DATABASE> is the name of the database you are connecting to (optional).
Hope this is what you need.
Similar Messages
-
Database Connection in SQL Server 2000
Hi All!
I would like to ask your expertise regarding JDBC-MS SQL Server 2000.
I have here a sample code in connecting to SQL Server 2000, AgriMrpPrd Database using the account "sa" and the password "092802". I have tried running the code in my local server at home and It successfully runs, but when I tried running it on my local server in the office, I was not able to create a connection object though I already have changed the HOST, PORT, DATABASE, USERNAME, and PASSWORD values.
I have tried logging in using my local account, removed the LAN connection, start my local server and tried connecting to it but still it does not work.
I have tried turning the firewall OFF and try reconnecting but it there was no improvement.
I do not know if there is a difference if there is my computer is on a DOMAIN (althought I am only connecting to my local server).
Source Code:
import javax.swing.*;
import java.sql.*;
import com.microsoft.jdbc.sqlserver.*;
public class SQLServerConnection{
public String un, pw, db, host, port, url, driver;
public Connection conn=null;
public void connectDB(){
String msg="",title="MS SQL Server - JDBC:ODBC Connection";
int msgType=0;
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
host="206.101.216.95";
port="1433";
un="sa";
pw="092803";
db="AgriMrpPrd";
url="jdbc:microsoft:sqlserver://" + host + ":" + port + ";DatabaseName=" + db;
try{
Class.forName(driver);
conn=DriverManager.getConnection(url,un,pw);
System.out.println("Connected to Database!");
}catch(Exception ex){
msg="Unable to connect to MS SQL Server!";
msgType=JOptionPane.ERROR_MESSAGE;
JOptionPane.showMessageDialog(null,msg,title,msgType);
System.exit(0);
public static void main(String args[]){
SQLServerConnection ssc=new SQLServerConnection();
ssc.connectDB();
Please give me wisdom in handling this problem...
Take care always and God blesss
MADzHi All!
I would like to ask your expertise regarding JDBC-MS
SQL Server 2000.
I have here a sample code in connecting to SQL Server
2000, AgriMrpPrd Database using the account "sa" and
the password "092802". I have tried running the code
in my local server at home and It successfully runs,
but when I tried running it on my local server in the
office, I was not able to create a connection object
though I already have changed the HOST, PORT,
DATABASE, USERNAME, and PASSWORD values.If the code runs in one place and not the other, it's got to be a problem with seeing the host.
I have tried logging in using my local account,
removed the LAN connection, start my local server and
tried connecting to it but still it does not work.
I have tried turning the firewall OFF and try
reconnecting but it there was no improvement.
I do not know if there is a difference if there is my
computer is on a DOMAIN (althought I am only
connecting to my local server).I have no idea how to fix your problem, but there are several things to comment on about your code:
(1) You don't have to import the microsoft package. It's actually a bad idea.
(2) I'd name this class DbConnection, because if you wrote it properly it might have a chance of being useful wih other databases, too.
(3) You hardwire all the connection information. Better to pass it in so changing the database doesn't require a recompile.
(4) It's bad to mingle Swing and database code. Take those JOptionPane calls out.
(5) Print the stack trace out when you catch an exception. You're losing a lot of information by handling it that way.
% -
Null connection when trying to connect to SQL Server 2000 in Tomcat4.1.29
Hi All,
I am still struggling with null connection when trying to connect to sql server 2000 with tomcat using sun.jdbc.odbc.JdbcOdbcDriver
Here is my server.xml
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<Resource auth="Container" description="Users and Groups
Database" name="UserDatabase"
scope="Shareable"
type="org.apache.catalina.UserDatabase"/>
<Resource name="jdbc/DefaultDS" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.
MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/DefaultDS">
<parameter>
<name>validationQuery</name>
<value></value>
</parameter>
<parameter>
<name>user</name>
<value>sa</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>sa</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:odbc:JBoss-SQL://localhost:1433;databaseName=Development;selectMethod=cursor;</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<!-- Define the Tomcat Stand-Alone Service -->
<Service name="Tomcat-Standalone">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8080" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
<!-- Note : To disable connection timeouts, set connectionTimeout value
to -1 -->
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 -->
<!--
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8443" minProcessors="5" maxProcessors="75"
enableLookups="true"
acceptCount="100" debug="0" scheme="https" secure="true"
useURIValidationHack="false" disableUploadTimeout="true">
<Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory"
clientAuth="false" protocol="TLS" />
</Connector>
-->
<!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
<!-- Define an AJP 1.3 Connector on port 8009 --><Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt"
timestamp="true"/>
<!-- Define the default virtual host -->
<Host name="localhost" debug="0" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<Environment name="maxExemptions" type="java.lang.Integer"
value="15"/>
<Parameter name="context.param.name" value="context.param.value"
override="false"/>
<Resource name="jdbc/DefaultDS" auth="container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/DefaultDS">
<!-- Maximum number of dB connections in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxActive</name>
<value>8</value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
-->
<parameter>
<name>maxIdle</name>
<value>4</value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<!-- MS Sql Server dB username and password for dB connections
-->
<parameter>
<name>user</name>
<value>sa</value>
</parameter>
<parameter>
<name>password</name>
<value>sa</value>
</parameter>
<!-- Class name for MS Sql Server JDBC driver
-->
<parameter>
<name>driverClassName</name>
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
<!-- The JDBC connection url for connecting to MS Sql Server dB.
-->
<parameter>
<name>url</name>
<value>jdbc:odbc:JBoss-SQL://localhost:1433;databaseName=Development;selectMethod=cursor;</value>
</parameter>
<!-- This Databae Connection Pool Description.
-->
<parameter>
<name>description</name>
<value>JDBC Driver: sun.jdbc.odbc.JdbcOdbcDriver</value>
</parameter>
</ResourceParams>
<Resource name="mail/Session" auth="Container"
type="javax.mail.Session"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
<ResourceLink name="linkToGlobalResource"
global="simpleValue"
type="java.lang.Integer"/>
</Host>
</Engine>
</Service>
</Server>
and my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- Standard Action Servlet Mapping -->
<web-app>
<resource-ref>
<res-ref-name>jdbc/DefaultDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
and JBoss-SQL is data source I created from control panel settings and here is way I am retrieving connetion
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/DefaultDS");
Connection con = ds.getConnection();
return con;
I tried connecting as mentioned in this website
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html#Common%20Problems.But didn't help
Please help urgent
Sorry for long file. Can any one please help me in solving this problem.
Thanks in advnace
KurakulaI'd recommend that you not use the JDBC-ODBC bridge driver to connect to SQL Server. M$ and jTDS are two free type IV JDBC drivers that you should use instead. Put those JARs in the WEB-INF/lib directory.
The database URL you're using is not correct if you change drivers. Consult the docs to find out what the proper syntax is.
MOD -
Connection with SQL Server 2000 to SQL Developer 1.2 Migration Workbench
Hi all,
I keep getting the following error with setup for SQL Developer 1.2 Migration Workbench connection to SQL Server 2000 database:
"Status: Failure -Network error IOException: Connection refused:connect"
I can access the Microsoft SQL Server 2000 database with username
and password using Enteprise Manager. However for some odd
reason the Oracle SQL Developer 1.2 cannot connect to it.I was having this problem too. I'll mangle this explanation, but Our SQLServer instance was on a local server with some named DNS something. So, to get to the server, we used theservername.outdomain instead of an IP. We could never get it to connect through the named server. We got an SQLServer instance going on a server that we could connect to through a regular IP, and it connected just fine.
Also, are you using the JTDS driver, or microsofts driver? We have only been able to connect with the JTDS driver. http://jtds.sourceforge.net/ -
How to connect MS SQL Server 2000 with JDeveloper 11g
Hi,
I am new to JDevleoper, Is it possible to connect MS SQL Server 2000 with JDeveloper 11g.
If possible can anyone help me in doing that?
waiting for ur reply...
Thanks in advance
Regards,
reddyShay or other knowledgeable folks,
Is there a way to utilize the wizard for "Business Tier > ADF Business Components > Business Components from Tables" for SQL Server 2000, 2005 or 2008. I can successfully execute sql via java programmatically or import a table from SQL Server with "Business Tier > ADF Business Components > Entity Object" wizard, but the Business Components from Tables simply doesn't see any tables under any schema. Without the "Business Components from Tables", i don't get the referential constraints imported into the application and to code all those from scratch is just not as elegant. So far i have only utilized the sql server jdbc driver from Microsoft (versions, 1.1, 1.2 and 2.0). Is there an alternative client that i need to use to enable selecting tables from that "Business Components from Tables" wizard. Is this a limitation of SQL Server, the jdbc driver or the wizard itself? Did anybody else experience the same issues? I am using Jdeveloper 11.1.1.0.1 against SQL Server 2005 (currently)
Thanks,
Andy -
Have anyone connected to sql server 2000 from forms 6i release 2
Have anyone connected to sql server 2000 from forms 6i release 2
on winNT 2000. sql server is also on same machine.
If yes then pls tell me details regarding
oca version
any patch required for forms 6i release 2(download location of
patch)
version of odbc drivers
or any other detils
urgent
thanks
yogeshrefresh
-
Can't connect to SQL Server 2000 from serlet
Hi,
I can connect to SQL Server 2000 from standalone program after set the classpath properly.
but I Can't connect to SQL Server 2000 from serlet, I am using Tomcat 4.1 and Win2K pro now. Do I need to set something for servlet just like CLASSPATH?
Any help will be appreciated.
package usingjsp;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
public class JDBCServlet extends GenericServlet
protected Connection conn;
public void init()
try
// Make sure the JdbcOdbcDriver class is loaded
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Try to connect to a database via ODBC
conn = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://hu:1433", "sa","");
catch (Exception exc)
// If there's an error, use the servlet logging API
getServletContext().log(
"Error making JDBC connection: ", exc);
public void service(ServletRequest request, ServletResponse response)
throws java.io.IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY>");
out.println("<PRE>");
out.println("The JDBC connection is:");
out.println(conn);
out.println("</PRE>");
out.println("</BODY>");
out.println("</HTML>");i also have this problem..do u have any solution?
-
Error while connecting to SQL Server 2000 using Heteregenous Services 11g
Hope this is the right thread to post on! We have been given the challenge of connecting to and reading data from a SQL Server 2000 database.
Our Infrastructure guys have set up the network access.
The SQL Server DB is set to windows NT Authentication only (N.B. NOT Mixed Mode) as there is an application running against the DB locally that will not run under Mixed Mode.
Our Oracle partner has download and installed the 11g Heteregenous Services. all works fine until the point we try to create the DBLink and then connect to the SQL Server DB when we get:
SQL> CREATE DATABASE LINK infoteam1.sco.infoteam.co.uk CONNECT TO "sco.infoteam.co.uk/infoteam" IDENTIFIED BY "########" USING 'dg4msql';
Database link created.
SQL> select * from "systables"@infoteam1.sco.infoteam.co.uk;
select * from "systables"@infoteam1.sco.infoteam.co.uk
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
[Oracle][ODBC SQL Server Driver][SQL Server]Login failed for user
'sco.infoteam.co.uk/infoteam'. Reason: Not associated with a trusted SQL Server
connection.[Oracle][ODBC SQL Server Driver]Invalid connection string attribute
ORA-02063: preceding 2 lines from INFOTEAM1.SCO.INFOTEAM.CO.UK
The question is can we (and if so how)?) connect to the SQL Server using an NT Windows Authorised account?
JeremyHi,
Please look at MOS note
ORA-28500: Generic connectivity using ODBC DSN over mapped drive fails [ID 105210.1]
Ora-28500 with Ms Sqlserver - Not associated with a trusted SQL Server connection [ID 333775.1]
Regards,
Edited by: gjilevski1 on Aug 31, 2010 8:23 AM -
Connecting to SQL Server 2000 with MS SQL Server Driver for JDBC
Hi,
I am brand new to JDBC . I have installed JDBC driver (for JDBC 2.0) from the Microsoft site and made relevant changes to the class path variable to include the driver paths, as suggested in the driver help documnnts. I have written a simple java code to register. But i get "class NotFound" error.
here's my code. What am I doing wrong? Thnaks for the help....
class Test {
public Test() throws Exception {
// Get Connection
// Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
DriverManager.registerDriver (new com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://SQL1:1433",myuser,mypwd);
if (conn != null) {
System.out.println();
System.out.println("Successful Connection");
System.out.println();
// Meta Data
DatabaseMetaData meta = conn.getMetaData();
System.out.println("\n Driver Information");
System.out.println("Driver Name: " + meta.getDriverName());
System.out.println("Driver Version: " + meta.getDriverVersion());
System.out.println("\n Database Information");
System.out.println("Database Name: " + meta.getDatabaseProductName());
System.out.println("Database Version: " + meta.getDatabaseProductVersion());
} //Test
public static void main(String [] args) throws Exception {
Test test = new Test();
}Hi MoD,
This is the exact command I used for compiling
C:\>javac -classpath "c:\java;c:\Program Files\Microsoft SQL Server 2000 Driver
for JDBC\lib\mssqlserver.jar;c:\Program Files\Microsoft SQL Server 2000 Driver f
or JDBC\lib\msbase.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDB
C\lib\msutil.jar" c:\java\Test.java
To Execute I used
C:\>java -classpath "c:\java;c:\Program Files\Microsoft SQL Server 2000 Driver
for JDBC\lib\mssqlserver.jar;c:\Program Files\Microsoft SQL Server 2000 Driver f
or JDBC\lib\msbase.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDB
C\lib\msutil.jar" c:\java\Test
In fact it kept thrwing up the Class Not Found error for the above commands.
But as U suggested I removed the classpath and executed both javac and java commands without classpath clause , and guess what it worked for the line
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
(i.e., it dint throw any exception like before). So can I assume that driver is successfully registered?
I tried using Jcreator for compile and run. But I got the same error msg as the commands given above with calsspath caluse. Is there a way around for this to make it work from an external editing tool like Jcreator apart from removing the classpath option from the JDKTool optional setting(doing this did not help for me)
Also one last favor: How do I connect with the trusted connection option? (i.e. it should use already logged in windows authentification login)
Thanks for all U'r help. I appreciate it very much.
Suma -
JDBC connection for SQL Server 2000
How to connect SQL Server 2000 from java?
If i can get any sites where i can get examples also fine.
Thanks in advance
Praveen.Developer's Daily Java Education
front page | java | perl | unix | DevDirectory
Front Page
Java
Education
Pure Java
Articles
JDBC 101: How to connect to an SQL database with JDBC
Introduction
If you're interested in connecting your Java applets and applications to standard SQL databases like Oracle, Informix, Sybase, and others, JDBC is your ticket to paradise. The combination of Java's JDBC and standard SQL makes a simple and powerful database solution. JDBC makes the simple things easy -- without making the complex tasks too difficult either.
In this first article in our series, we'll show you step-by-step how to establish a connection from your Java programs to an SQL database using JDBC. In the process we'll show you how to connect to two different databases -- Mini SQL (mSQL), and Interbase -- just so you can see how the code changes when you switch from one database to another.
Obtaining the JDBC driver
Before you start working with JDBC, you'll need a copy of the Java JDK. If you don't have it already, you can get the JDK for free at Sun's Java web site, or it will also be included with many IDE's that you can purchase, such as JBuilder or Visual Cafe.
Once you have the JDK, the next thing you need to do is to get the correct JDBC driver for your database. In most cases the JDBC driver will be provided by your database vendor. For instance, if you purchase the Interbase database, the driver will be provided with the software, or you can obtain the most recent version at http://www.interbase.com/.
(An exception to this rule is Mini SQL, or mSQL. Because it's a very low-cost database, the JDBC driver has actually been developed by a separate group of people, led by George Reese at imaginary.com. You can download the mSQL JDBC driver from the imaginary.com web site.)
Once you have the correct JDBC driver for your database, install it according to the instructions that came with it. Installation instructions will vary somewhat for each vendor.
Establishing a connection is a two-step process
Once you have the correct JDBC driver installed, establishing a connection from your Java programs to your SQL database is pretty easy.
Regardless of whether you're trying to connect to Oracle, Sybase, Informix, mSQL, or Interbase (or any other JDBC data source), establishing a connection to an SQL database with Java JDBC is a simple two-step process:
Load the JDBC driver.
Establish the connection.
We'll show you two examples just so you can see how easy it is, and how little the code changes when you migrate from one database server to another.
A Mini SQL Example
Listing 1 provides the full source code required to establish a connection to a mSQL database on a server named "www.myserver.com".
// Establish a connection to a mSQL database using JDBC.
import java.sql.*;
class JdbcTest1 {
public static void main (String[] args) {
try {
// Step 1: Load the JDBC driver.
Class.forName("com.imaginary.sql.msql.MsqlDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc:msql://www.myserver.com:1114/contact_mgr";
Connection conn = DriverManager.getConnection(url,"user1","password");
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
Listing 1: This source code example shows the two steps required to establish a connection to a Mini SQL (mSQL) database using JDBC.
An Interbase Example
Listing 2 provides the full source code required to establish a connection to an Interbase database. In this example, we're connecting to a local Interbase server (i.e., the server is running on the same PC that we're running the Java code on).
// Establish a connection to an Interbase database using JDBC.
import java.sql.*;
class JdbcTest1 {
public static void main (String[] args) {
try {
// Step 1: Load the JDBC driver.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Step 2: Establish the connection to the database.
String url = "jdbc:odbc:contact_mgr";
Connection conn = DriverManager.getConnection(url,"user1","password");
} catch (Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
Listing 2: This source code example shows the two steps required to establish a connection to an Interbase database using JDBC.
What's the difference?
The difference between the two source code listings is very small, so we highlighted them in a dark blue color. The only difference between connecting to the two databases is:
The name of the JDBC driver.
The URL used to connect to the database.
Everything else in the two source code listings -- except for the comment at the top -- is identical. Here's a slightly more detailed discussion of the two differences:
1. The JDBC Driver
The name of the JDBC driver will be supplied to you by your database vendor. As you can see in the class.forName() statements, these names will vary. In the first case we're using the mSQL-JDBC driver. In the second case we're using the JDBC-ODBC Bridge driver supplied with the Interbase server.
2. The URL
The syntax of the DriverManager.getConnection() method is:
DriverManager.getConnection(String url, String username, String password);
The username and password are the normal names you use to log into your database. The URL you use will again vary with the database you use. In both examples shown, we're establishing a connection to a database named contact_mgr. (We'll use this database for all of our examples in this series of JDBC articles.)
If you stick with standard SQL commands, it can be very easy to switch from one database server to another. In fact, I've heard from several developers who are using mSQL to prototype their software (because it's so inexpensive), and then switching to another commercial vendor when it's time to take their product "live".
Conclusion
Establishing a connection to an SQL database with Java JDBC is a simple, two-step process. The process is nearly identical for all SQL databases, and the only real differences are (a) the driver name, and (b) the URL used to connect to the database. Your database vendor will provide this information in their documentation.
Resources mentioned in this article
Here are a few links to resources we mentioned in this article:
Interbase
The Mini SQL (mSQL) database
The mSQL-JDBC driver at imaginary.com
[an error occurred while processing this directive]
-
Can't connect to sql server 2000
hellow guys...
i install j2sdk1.4.1, j2sdkee1.4 and im using driver from microsoft (msutil,mssqlserver,msbase.jar)and the class path is c:\j2sdkee1.4\lib\;c:\j2sdkee1.4\lib\j2ee.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msbase.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\msutil.jar;c:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\mssqlserver.jar;c:\j2sdkee1.4\bin
the path is : c:\j2sdk1.4.1_01\bin;c:\j2sdkee1.4\bin;
im using win2000pro. and here is my script:
import java.io.*;
import javax.servlet.*;
import java.sql.*;
import javax.servlet.http.*;
public class dbsample extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;sa;");
Statement stmt = conn.createStatement();
ResultSet RS = stmt.executeQuery("SELECT * FROM Table1");
if (RS != null)
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("ok");
while(RS.next())
out.println(RS.getString("row")+"<br>");
response.flushBuffer();
stmt.close();
conn.close();
} catch(Exception e){
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Error: "+e);
===> i got an error in the browser just like this :
Error: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
please anybody help me..... thankx.... god bless youThe driver connects to the default database of the user used to connect to the server, unless otherwise specified this is the table 'master'
to connect to your 'test' database, change your connectstring so it includes the database name. Also (but this is a question of flavour I think), I prefer to provide the user and password as separate parameters:
String user = "sa";
String pass = "****";
String cUrl = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test";
Connection conn = DriverManager.getConnection (cUrl, user, pass); -
JDBC connection to SQL Server 2000 Service Pack 4
Hello Everyone,
I'm trying to do a simple application which save some values into a MS SQL Server 2000 Database's Table.
The source code I've written is:
package Logging;
import com.brekeke.net.sip.sv.session.*;
import com.brekeke.net.sip.sv.session.plugins.*;
import java.io.*;
import java.util.*;
import java.sql.*;
public class Logging extends AccountingBase {
public int eventSessionStart( EventStat evstat, String[] argprm )
int ris =0;
int line=999;
try {
EventStat a;
a = evstat ;
String username;
username=a.urlCaller;
String callee;
callee=a.urlCallee;
Statement stmt = null;
try {
line=1;
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
line=2;
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://BSSQL:1433;DataBaseName=Test;User=sa;Password=biesse");
line=3;
// Create and execute an SQL statement that returns some data.
String SQL = "INSERT INTO log VALUES ('" + a.urlCaller + "','" + a.urlCallee + "')";
line=4;
stmt = conn.createStatement();
line=5;
line=stmt.executeUpdate(SQL);
line=10;
catch (Exception e) {
e.printStackTrace();
finally {
if (stmt != null) try { stmt.close(); } catch(Exception e) {}
File f = new File("c:/prova.txt");
FileOutputStream fos=new FileOutputStream(f);
PrintStream ps=new PrintStream(fos);
ps.println(line);
ps.println(a.urlCaller);
ps.println(a.urlCallee);
fos.close();
catch ( Exception ex ) {
return ris;
The problem is that into the Table no value is written, no problem compiling it and into the file prova.txt I can see only the value line=1 written!
So there should be something wrong in the connection.
I've already installed the JDBC drivers for SQL Server 2000 and I've addedd into the libraries the "msbase.jar, the mssqlserver.jar and the msutil.jar".
But nothjng written into the Database :-(
Can you help me please?
Thank you very much in advance,
Best Regards
FrancescoHi,
Yes i am able to connect from ISQL. Only connecting from JDBC is a problem. -
Can not read Chinese data when DB Connect to SQL server 2000
Hi,
Our BW server( BW3.5 not unicode ) is installed on MS SQL server 2000. We try to connect the BW SQL server with db connect function. We create some test views in the Northwind DB. We are be able to access data from source system in rsa1 by db connect. The problem is that all the Chinese characters are displayed as ?????. Is there any special setting for accessing multibyte characters in MS SQL server 2000? Please advise.
Thank you,
JeffThe field of VIEW in the sqlserver which code is chinese must be the nvarchar.
You can try it. -
Open Connection to SQL Server 2000 Instances
Dear All:
I always got following error when connecting to a SQL Server 2000 instance:
"Can't open a socket on NAMNGO\RNDSQLSVR:1433. Check host and port number and
make sure the
security manager allows this connection. You can also try running the SocketApplet
(java.net.UnknownHostException:
NAMNGO\RNDSQLSVR)"
I am using Wel Logic 6.1 and SQL Server 2000. SQL Server 2000 has an instance
named RNDSQLSVR with default TCP port is 1433.
Is there anyone hit this problem, please let me know.
Please check the attached file for sample code.
Thanks,
Nam Ngo
[att1.html]Hi Sree,
Thank you for your help. It worked.
Nam Ngo
"Sree Bodapati" <[email protected]> wrote:
Hi Nam,
The way you do this is by finding out on what port the instance of SQL
Server you want to connect is listening on. (Use the server network utility
that comes with SQL Server 2000 for this). Then just mention the
server=<machine name/ip> of the server this instance is running on. and
the
port as the port that is shown by the server network utility as port=<port
number>. Microsoft specifies NAMNGO\RNDSQLSVR:1433 as the convention
for
ODBC but , this driver is a type 4 driver and it needs only the machine
name
and port, it doesnt need any instance name.
(Each instance of SQL Server 2000 listens at a different port)
HTH
sree
"Nam Ngo" <[email protected]> wrote in message
news:[email protected]..
Dear All:
I always got following error when connecting to a SQL Server 2000instance:
"Can't open a socket on NAMNGO\RNDSQLSVR:1433. Check host and portnumber
and
make sure the
security manager allows this connection. You can also try running theSocketApplet
(java.net.UnknownHostException:
NAMNGO\RNDSQLSVR)"
I am using Wel Logic 6.1 and SQL Server 2000. SQL Server 2000 has aninstance
named RNDSQLSVR with default TCP port is 1433.
Is there anyone hit this problem, please let me know.
Please check the attached file for sample code.
Thanks,
Nam Ngo -
I am working on application integration, and one application resides in an Oracle 8.0.5 database and the other is in a Microsoft SQL Server 2000 database. The question I have is that I am trying to create a database link within the Oracle database that points to the SQL Server database. How do I accomplish this?
i think you need to have oracle gateway
transparent layer inorder to connect to non oracle db and then u can have database link pointing to sqlserver.
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Judson Plapp ([email protected]):
I am working on application integration, and one application resides in an Oracle 8.0.5 database and the other is in a Microsoft SQL Server 2000 database. The question I have is that I am trying to create a database link within the Oracle database that points to the SQL Server database. How do I accomplish this?<HR></BLOCKQUOTE>
null
Maybe you are looking for
-
i am adding a string to an array but first have to check if it is already present. The code i had was trying is //B is capacity of array //adding from B downwards //add is set when a new string is added for(int search = B; search != add; search--){ i
-
Hi, All, Is there any way to know how many open purchase order quantity in the SAP system? If I want to differentiate different business unit open purchase order, how I can do? What's the T-code? Thanks
-
Process: Mail [3780] Path: /Applications/Mail.app/Contents/MacOS/Mail Identifier: com.apple.mail Version: 6.5 (1508) Build Info: Mail-1508000000000000~3 Code Type: X86-64 (Native) Parent Process: launchd [1
-
Acer Aspire V17 Nitro Black Number Lock
I know this has been asked before but the answers given have not worked.1. Edit the registery.2. Disable fast startup.I have an Acer Aspire V17 Nitro Black (VN7-791G) with Windows 8.1. I want Num Lock on always. When I boot the machine in the mor
-
Is there any way to get hold of the digital audio from an iPhone 4S without buying a dock? I was planning on getting an FiiO E17 portable dac/headphones amp, so keeping it portable, I wish for a simple solution which fits with this.