MS SQL Server 2000 + JDBC
Hi everyone,
I know many of you don't like microsoft products, but I am getting weird errors when i connect my java program to SQL server 2000 with its driver. My code worked FINE with MS Access. The thing is I know there are some bugs to SQL server driver , and somebody knowledgeable with this software could def help me fix the problem, but i searched all over the microsoft site, couldnt find a fix to my problem, and contacting microsoft for help costs between $195-$245. I was wondering if somebody here is familiar with this software. I would really appreciate it if you could email me at [email protected] I will post all of the problem here also.
I'm getting the following error when i try to create a insert a new function (create a new row) in my database:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Incorrect syntax near the keyword 'Function'.
Here is the relevant code:
<code>
try{
DriverManager.registerDriver(new com.microsoft.jdbc.sqlserver.SQLServerDriver() );
} catch (Exception e) {
System.out.println(e.getMessage());
try{
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://NJ8650MONDAL", "m", "m");
con.setAutoCommit(false);
PreparedStatement insertFvalues = con.prepareStatement("INSERT INTO function_description (Function, Description, Notes) VALUES (?,?,?)");
insertFvalues.setString(1,functionname);
insertFvalues.setString(2,descriptionname);
insertFvalues.setString(3,notesname);
insertFvalues.execute();
PreparedStatement insertRvalues = con.prepareStatement("INSERT INTO return_code_description (Function_Name, Return_Codes, Return_Codes_Description) VALUES (?,?,?)");
insertRvalues.setString(1,functionname);
insertRvalues.setString(2,rvvaluesname);
insertRvalues.setString(3,rvdescripname);
insertRvalues.close();
con.commit();
insertFvalues.close();
insertRvalues.close();
con.close();
} catch (SQLException e) {System.out.println(e.getMessage());
}</code>
thanks. i fixed that error, so now that portion works. however, i have a question..
SQL server does not allow comparisons between text fields unless the IS NULL or LIKE operators are used. I'm using JDBC to load exisiting entries from the database and display them in a gui. THe thing is I have one main table, which has a one-to-many relationship with my other tables..so the way i linked them was to have one column in each table hold the same text data, and then i can use the = operator to see if there are matches..
for example one table (function_description) has the following data:
Function_Name_Ind Description Notes
sample blah blah
And another table (return_code_description)has the following data:
Function_Name Return_Code Return_Code_Description
sample x xx
sample y yy
And I want all of this displayed.
i don't know if that explanaiton is any good, but seeing the code below might help you understand..
<code>
try{
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://NJ8650MONDAL", "m", "m");
con.setAutoCommit(true);
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("SELECT * FROM function_description, return_code_description " + "WHERE function_description.Function_Name_Ind = return_code_description.Function_Name AND (((Function_Name_Ind)='"+ functionname + "'))");
result.next();
function.setText(result.getString("Function_Name_Ind"));
description.setText(result.getString("Description"));
notes.setText(result.getString("Notes"));
rvalues.setText(result.getString("Return_Codes"));
rvdescrip.setText(result.getString("Return_Codes_Description"));
stmt.close();
con.close();
} catch (SQLException e) {System.out.println(e.getMessage());
</code>
And i'm getting this error.
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Can any of you think of another way I can do this? IS there another way in JDBC I can write it?
thanks!
Similar Messages
-
MS SQL Server 2000 JDBC Driver + Tomcat 4
Will the MS SQL Server 2000 JDBC Driver (http://www.microsoft.com/SQL/downloads/2000/jdbc.asp) work with a JSP application on the Tomcat Server. The JSP is to access a MS SQL Server Database. Would it b able to do this with this Driver or do I need another one (type) for Tomcat?
Thanx
YazHi Yasir,
1. It should be OK.
(2. Check the requirement to see if you have everything)
--Paul. -
MS SQL Server 2000 JDBC driver and databasename
Hi,
I have tried to switch from using WebLogic jDriver for MS SQL Server to using
MS SQL Server 2000 JDBC Driver as recommended by Bea for WebLogic 7.0. I can get
the connection pooling to work with the new driver but I cannot get it to work
for certain database. It seems to always connect to the defaul database even though
I specify the database in console with property databasename=DBNAME. Any ideas
what could be wrong?
Thanks!
Cheers,
JouniWe had this working fine with WLS7, this is the entry from our config.xml
<JDBCConnectionPool DriverName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
InitialCapacity="50" MaxCapacity="50" Name="SQLServerConnectionPool" Password="{3DES}UkODkM1JaCU="
Properties="user=Destin8;SelectMethod=cursor;databaseName=Destin8V3" ShrinkingEnabled="false"
Targets="Destin8Cluster1" URL="jdbc:microsoft:sqlserver://mcp1:1433"/>
Hope this helps..
Pete
"Jouni Peltonen" <[email protected]> wrote:
>
Hi,
I have tried to switch from using WebLogic jDriver for MS SQL Server
to using
MS SQL Server 2000 JDBC Driver as recommended by Bea for WebLogic 7.0.
I can get
the connection pooling to work with the new driver but I cannot get it
to work
for certain database. It seems to always connect to the defaul database
even though
I specify the database in console with property databasename=DBNAME.
Any ideas
what could be wrong?
Thanks!
Cheers,
Jouni -
Java Web Server 6.1 & Pooled SQL Server 2000 JDBC Connections
If anyone can shed some light on this problem I would greatly appreciate it.
I am unsuccessfully trying to use a database connnection retrieved from a pool configured using Java System Web Server 6.1 with the SQL Server 2000 JDBC Driver.
The background:
1. I have downloaded the SQL Server 2000 JDBC Driver and installed it on the web server.
2. I used the Administration GUI to add the .jars(namely msbase.jar, msutil.jar, and mssqlserver.jar), to the classpath.
3. Upon creating a simply JSP to access connection metadata using the direct connect method, ie.,
Class.forName( com.microsoft.jdbc.sqlserver.SQLServerDriver);
Connection con = DriverManager.getConnection( "jdbc:microsoft:sqlserver:// ....
I am shown a successful output of...
JDBC Test
Registering JDBC Driver
driverClass: com.microsoft.jdbc.sqlserver.SQLServerDriver loaded and registered.
Driver Information
Driver Name: SQLServer
Driver Version: 2.2.0037
Database Information
Database Name: Microsoft SQL Server
Database Version: Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.2 (Build 3790: )
Avalilable Catalogs
catalog: master
catalog: msdb
catalog: Northwind
catalog: pubs
catalog: tempdb
4. This tells me that the web server has access to the files necessary and the classpath is configured correctly.
Now the fun begins...
In order to set up the JDBC Connection Pool I have done the following...
1. I have created a web.xml file for the web-app which contains the JSP and includes the following entry
<resource-ref>
<res-ref-name>jdbc/devjwscp</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
2. I have used the "JDBC Connection Pools" link under the "Java" tab in the Administration GUI to create a connection pool.
"Pool Name:" is "devjwscp"
"DataSource Classname" is set to "com.microsoft.jdbcx.sqlserver.SQLServerDataSource". All other properties have been left alone.
3. I have used the "JDBC Resources" link under the "Java" tab in the Administration GUI to create a JNDI resource.
"JNDI Name" is set to "jdbc/devjwscp"
"Status" is "true"
"Pool Name" is "devjwscp"
The web-app JSP comes back with the following exception.
JDBC Test
Exception Thrown
Cannot create resource instance
javax.naming.NamingException: Cannot create resource instanceorg.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:167)
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301)
org.apache.naming.NamingContext.lookup(NamingContext.java:834)
org.apache.naming.NamingContext.lookup(NamingContext.java:181)
org.apache.naming.NamingContext.lookup(NamingContext.java:822)
org.apache.naming.NamingContext.lookup(NamingContext.java:181)
org.apache.naming.NamingContext.lookup(NamingContext.java:822)
org.apache.naming.NamingContext.lookup(NamingContext.java:181)
org.apache.naming.NamingContext.lookup(NamingContext.java:822)
org.apache.naming.NamingContext.lookup(NamingContext.java:194)
org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
javax.naming.InitialContext.lookup(InitialContext.java:347)
_jsps._jdbctest_jsp._jspService(_jdbctest_jsp.java:236)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:667)
com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:447)
com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:363)
javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
com.iplanet.ias.web.WebContainer.service(WebContainer.java:586)
4. FYI my server.xml <RESOURCE> entry looks as is shown below
<RESOURCES>
<JDBCCONNECTIONPOOL name="devjwscp" datasourceclassname="com.microsoft.jdbcx.sqlserver.SQLServerDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="off" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off" transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
<PROPERTY name="serverName" value="secret"/>
<PROPERTY name="portNumber" value="1433"/>
<PROPERTY name="User" value="secret"/>
<PROPERTY name="Password" value="secret"/>
</JDBCCONNECTIONPOOL>
<JDBCRESOURCE jndiname="jdbc/devjwscp" poolname="devjwscp" enabled="on"/>
</RESOURCES>
What gives? Do I need to add anything else to the server.xml? I know the server.xml for JWS differs from Apache. I have done an exhaustive search of the web. Many other individuals have had the same thing happen, buy none of them offered any explaination or remedy.
Thanks in advance.Hi,
Were you able to get it working.
I am using
Sun ONE Web Server 6.1SP2 B04/07/2004 18:47
I am still getiing the same error. I also suspect that there is something wrong with thr DTD too. It gives me the following when the server comes up.
Sun ONE Web Server 6.1SP2 B04/07/2004 18:47
Listening for transport dt_socket at address: 1699
info: CORE5076: Using [Java HotSpot(TM) Server VM, Version 1.4.2_04] from [Sun M
icrosystems Inc.]
info: WEB0100: Loading web module in virtual server [https-AW-NYNY-D609628.nna.
wdpr.disy.com] at [acsanet]
info: WEB0100: Loading web module in virtual server [https-AW-NYNY-D609628.nna.
wdpr.disy.com] at [testing]
failure: WEB0120: XML error parsing deployment descriptor [C:/Sun/WebServer6.1/h
ttps-AW-NYNY-D609628.nna.wdpr.disy.com/webapps/https-AW-NYNY-D609628.nna.wdp
r.disy.com/testing/WEB-INF/sun-web.xml]
Failed to create the XML-DOM Document. Check your XML to make sure it is correc
t.org.xml.sax.SAXParseException: Character conversion error: "Unconvertible UTF-8
character beginning with 0xa0" (line number may be too low).
at org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1100)
at org.apache.crimson.parser.InputEntity.fillbuf(InputEntity.java:1072)
at org.apache.crimson.parser.InputEntity.isXmlDeclOrTextDeclPrefix(Input
Entity.java:914)
at org.apache.crimson.parser.Parser2.maybeXmlDecl(Parser2.java:1183)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:653)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
at org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl
.java:185)
at org.netbeans.modules.schema2beans.GraphManager.createXmlDocument(Grap
hManager.java:711)
at org.netbeans.modules.schema2beans.BaseBean.createGraph(BaseBean.java:
2075)
at com.iplanet.ias.web.WebContainer.loadWebModule(WebContainer.java:695)
at com.iplanet.ias.web.WebContainer.loadStandaloneWebModule(WebContainer
.java:626)
at com.iplanet.ias.web.WebContainer.loadWebModules(WebContainer.java:600)
at com.iplanet.ias.web.WebContainer.createVS(WebContainer.java:374)
at com.iplanet.ias.server.J2EERunner.createVS(J2EERunner.java:223)
info: WEB0100: Loading web module in virtual server [https-AW-NYNY-D609628.nna.wdpr.disy.com] at [search]
config: HTTP4292: flex-init: Log file C:/Sun/WebServer6.1/https-AW-NYNY-D609628.
nna.wdpr.disy.com/logs/access should be removed before changing its format
info: HTTP3072: [LS ls1] http://AW-NYNY-D609628.nna.wdpr.disy.com:80 ready to
accept requests
startup: server started successfully
info: CORE3274: successful server startup
the sun-web.xml is as below:
<?xml�version="1.0"�encoding="UTF-8"?>
<!--
Copyright 2002 Sun Microsystems, Inc. All rights reserved.
-->
<!DOCTYPE�sun-web-app�PUBLIC�"-//Sun�Microsystems,�Inc.//DTD�Application�Server�8.0�Servlet�2.4//EN"�"http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-0.dtd">
<sun-web-app>
<resource-ref>
<res-ref-name>jdbc/oraclePool</res-ref-name>
<jndi-name>jdbc/oraclePool</jndi-name>
</resource-ref>
</sun-web-app>
Am I using the right DTD ?
Please let me know.
Thank you.
-- Martin Louis -
Where to find the API documentation for MS SQL Server 2000 JDBC
I Downloaded and installed the MS SQL Server 2000 JDBC package, but I found that it does not provide enough help docs such as API documentation, demo and etc.
It would be most grateful if you would provide some information about this driver.Thank your for your kind attention.
For example, I want to get a ConnectionPoolDataSource object to get a PooledConnection object, but I don't know which class implements the interface.
import java.sql.*;
import javax.sql.*;
import <classes related to connection pooling>;
ConnectionPoolDataSource cpds = new <MS impl>;
<lines for setURL()/setUser()/setPassword, etc>
PooledConnection pc = cpds.getPooledConnection();
... -
SQL Server 2000 Jdbc connection
I just have a small question and I was wondering if anyone could help me out with it? I'm using a JSP page to connect up to the database on the server. I have the JDBC driver and am trying to connect from my machine to SQL Server 2000 on our server. The thing is I'm having a little trouble with the connection string.
(i am using the Microsoft SQL Server 2000 JDBC Driver)
Can you use Windows Authentication when using the connection string?
Also i tried using a SQL Server connection but it gave me the error : "com.microsoft.sqlserver.jdbc.SQLServerExcepti on: Login failed for user 'Arun'. The user is not associated with a trusted SQL Server connection. "
This is the connection string
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection connection1 = java.sql.DriverManager.getConnection("jdbc:sqlserver://localhost:1433;Database=BusinessDatabase","Arun","testpass");can you set it up for windows authentication?
thanks for any help anyone can give me with this! <img src="http://www.java-forums.org/images/smilies/smile.gif" border="0" alt="" title="Smile" width="16" height="16" />Hi,
Yes, it is possible to use Windows Authentication but you will need to make sure the sqljdbc_auth.dll file is in your system path specified with the -Djava.library.path="xxx" option. The dll is included as part of the JDBC Driver download.
Hope this helps.
Ben. -
I installed the Jdbc driver for sql server 2000 and set the classpath. When when I was trying to
connect to the sql server database from a java program, I kept getting the following error;
There was an error connecting to the DataSource: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'jet123'. Reason: Not associated with a trusted SQL Server connection.
The whole scenario is like this:
I have a sql server 2000 installed in my windows 2000 machine, and I created a MISM\myBase server under the SQL Server group, where MISM is the name of my machine, and myBase is the name of the sql server. Under the MISM\myBase server I created a database named "Aromatherapy". I added new login(username:jet123, passwd:1001) to the MISM\myBase server and also added user jet123 to the Aromatherapy database. The login(jet123, 1001) is my user name and passwd to my windows machine and has the administrator privillege.
Here is the code:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://128.2.76.102:1433;databasename=Aromatherapy;user=jet123;password=1001");
Could anyone help?
Thanks,
Davidmake sure that user jet123 access to the sql server used by ms-sql queryanlayzer
not?
first check if your sql authentication mode is windows and sql server
or, allow the permistion to jet123 to access the database, by ordinary to be db_owner. -
Hi,
Im trying to get my java program to connect to MSSQL but the drivers dont want to work.
Basically what I did is installed the drivers from MS, and also tried to set Classpath to
C:\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib\
But it doesnt work. Is there anything I should know besides this? Also can someone please give me sample code to send and recieve data? It is so hard to find a simple working code online.
ThanksHi,
Im trying to get my java program to connect to MSSQL
but the drivers dont want to work.
Basically what I did is installed the drivers from
MS, and also tried to set Classpath to
C:\Program Files\Microsoft SQL Server 2000 Driver for
JDBC\lib\Install and CLASSPATH aren't going to cut it. Use "java -classpath <path to JAR>" YourClass to run on the command line. If it's a Java EE app, put the JAR in the appropriate place (e.g., WEB-INF/lib for web apps).
% -
MS SQL Server 2000 JDBC Settings
Hi,
I am new to weblogic and i am developing my final year project using weblogic 8.1 SP 3.0. I want to use MS SQL Sever as a database. Can anyone tell me how to configure MS SQL Server for weblogic and how to communicate with it with the help of an example. I have tried my best to configure it by searching material but it is not working. Please help. You can also send me the reply on my email id i.e [email protected]
Regards,
SameeR.Deepak Vohra wrote:
Thanks for trying to help, but this below is unnecessary and counter-productive.
WebLogic comes already with a comprehensively superior JDBC driver for MS SQLServer
(2000 and up). Just follow the documentation at:
http://e-docs.bea.com/wls/docs81/jdbc_drivers/mssqlserver.html#1043185
Joe
To configure WebLogic with SQL Server:
1. Install the SQL Server with SQL2kdesksp3.exe
2. Add the SQL Server driver jar files msbase.jar, msutil.jar and mssqlserver.jar to the Classpath in the startWebLogic script.
3. In the administration console configure a new JDBC connnection. In the Configure a JDBC Connection Pool frame select MS SQL Server in the Database Type field. Select Microsoft???s MS SQL Server Driver (Type 4 ) driver as the Database Driver.
4. In the Connection Properties frame specify the Host Name as localhost, Port as 1433, Database User Name as sa and Password as the password used login to the database.
5. In the Test database connection frame specify the Driver Classname as com.microsoft.jdbc.sqlserver.SQLServerDriver, URL as jdbc:microsoft:sqlserver://localhost:1433
6. In the Create and deploy frame select the server to which the JDBC Connection pool is to be deployed. -
SQL Server 2000 - JDBC + Java Applet problem
Hai
I have some problem connecting my SQL server database with Java.
I use Applet to make my interface.
I use Windows 2000 server.
Here is my program listing :
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.sql.*;
public class VLookup extends JApplet {
String database = "jdbc:odbc:Driver={SQL Server};SERVER=Windows2000;uid=sa;pwd=;Database=User-Phone Database";
String user = "sa";
String password = "";
Statement s;
Connection c;
JTextField searchFor = new JTextField(10);
JLabel completion = new JLabel(" ");
JTextArea results = new JTextArea(40, 20);
public void init() {
searchFor.getDocument().addDocumentListener(new SearchL());
JPanel p = new JPanel();
p.add(new Label("ID to search for :"));
p.add(searchFor);
p.add(completion);
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
cp.add(p, BorderLayout.NORTH);
cp.add(results, BorderLayout.CENTER);
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection(database, user, password);
s = c.createStatement();
} catch(Exception e) {
results.setText(e.getMessage());
class SearchL implements DocumentListener {
public void changedUpdate(DocumentEvent e){}
public void insertUpdate(DocumentEvent e){
textValueChanged();
public void removeUpdate(DocumentEvent e){
textValueChanged();
public void textValueChanged() {
ResultSet r;
if(searchFor.getText().length() == 0) {
completion.setText("");
results.setText("");
return;
try {
r = s.executeQuery("SELECT " + "Tipe " + "FROM " + "Time " + "WHERE " + "(Tipe Like '" + searchFor.getText() + "%') "
+ "GROUP BY " + "Tipe " + "ORDER BY " + "Tipe " );
if(r.next())
completion.setText(r.getString("Tipe"));
r = s.executeQuery("SELECT " + "ID_Pengguna, Phone_Number, Tipe " + "FROM " + "Time "
+ "WHERE " + "(Tipe ='" + completion.getText() + "') "
+ "GROUP BY " + "ID_Pengguna, Phone_Number, Tipe "
+ "ORDER BY " + "ID_Pengguna, Phone_Number " );
} catch(Exception e) {
results.setText(searchFor.getText() + "\n");
results.append(e.getMessage());
return;
results.setText("");
try {
while(r.next()) {
results.append(r.getString("ID_Pengguna") + ", " + r.getString("Phone_Number") + ", " + r.getString("Tipe") + "\n");
} catch(Exception e) {
results.setText(e.getMessage());
public static void main(String[] args) {
JApplet applet = new VLookup();
JFrame frame = new JFrame("User ID");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){
System.exit(0);
frame.add(applet);
frame.setSize(500, 200);
applet.init();
applet.start();
frame.setVisible(true);
} ///:~
And java catch error like this : access denied (java.lang.RuntimePermission access ClassInPackage.sun.jdbc.odbc)
What is wrong ??
Is there any problem with my DNS ? 'cos I don't know how to set up my DNS.
Can u help my with this problem ??
Thank'sYou need to read up on what applets are capable of. Applets generally cannot open connections to things like databases due to sandboxing. There are a couple of ways to get around this. The applet can connect to a servlet on the same machine from which it came and have the servlet do the database accesses. Alternately, you can create a signed applet which allows you to get around some of these sandboxing issues.If tried to make localhost on my computer ( by setting my IIS configuration setting, and using Configure SQL XML Support in IIS I've created a new http://localhost/skripsi to my SQL database.
Is there any command that I have to add to my program listing so the applet can work as I wish ??
Is there any way to use applet to connect my database withaout using servlet, and can u explain siggned applet to mey ??
Sorry, I don't really know java very well.
driver type 4 ?? -
JDBC Connection between Unix and SQL Server 2000
I have SQL Server 2000 installed in a pc as a data server and SQL Server 2000 JDBC Drive installed in a Unix machine. Both machines are connected and can ping each other. After setting up the environment data, I ran a test code to test the connection and got exceptions. ( I did the same process between a pc and the data server, it works well.)
Attached are the test code and error message. Hope someone can help me.
******* Test Code ********
import java.sql.*;
* Microsoft SQL Server JDBC test program
public class Test {
public Test() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://<hostname>","<username>","<password>");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("\nDatabase 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();
******* error message ********
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Compiled Code)
at java.sql.SQLException.<init>(SQLException.java:64)
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Compiled Code)
at java.sql.DriverManager.getConnection(DriverManager.java:137)
at Test.<init>(Test.java:10)
at Test.main(Test.java:32)
************ end of message ***********If it works from a PC and not from the Unix box then you may have a network issue of some sort, I.E. firewall not letting it through etc.
Try using telnet on the Unix box to see if you can connect to the sql server on the port that the SQL server is listening.
E.G.
telnet server_name 1433
You may need to change the port number to the one that the SQL server is using.
Col -
I am using JDK 1.5 and I want to make a connection to Microsoft SQL Server 2000. I got the driver from the site of Microsoftand named Microsoft SQL Server 2000 JDBC Driver Service Pack 3. This was the latest version of this driver. And have used this code to test the driver:
=====================================================
import java.sql.*;
* Microsoft SQL Server JDBC test program
public class Test {
public Test() throws Exception {
// Get connection
DriverManager.registerDriver(new
com.microsoft.jdbc.sqlserver.SQLServerDriver());
Connection connection = DriverManager.getConnection(
"jdbc:microsoft:sqlserver://EXPERT:1433;User=sa;Password=123");
if (connection != null) {
System.out.println();
System.out.println("Successfully connected");
System.out.println();
// Meta data
DatabaseMetaData meta = connection.getMetaData();
System.out.println("\nDriver Information");
System.out.println("Driver Name: "
+ meta.getDriverName());
System.out.println("Driver Version: "
+ meta.getDriverVersion());
System.out.println("\nDatabase 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();
====================================================
but it doesn't work. the error is:
Exception in thread "main" java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSLoginRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Test.<init>(Test.java:10)
at Test.main(Test.java:31)
====================================================
Can anybody help me to find a solution?Hi,
The Microsft JDBC driver supplied by Microsoft does not work for local SQL Server run on Windows2000 professional/personal. If your local OS is Windows 2000 Server, then the JDBC Driver supplied from the microsoft website may work.
(I am not sure about other Windows OS' like XP/95/98 etc.)
As a workaround you can use an alternative driver from JTDS or drivers from DataDirect Connect.
I faced similar issue as yours trying to connect to the local SQL database running in my machine with OS Windows2000 professional. I was able to solve the issue and connect to the DB when I used the JTDS Driver from sourceforge.net. This is an free software open source from GNU.
JTDS is a Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000 and 2005) and Sybase (10, 11, 12).
You can also check for DataDirect's driver in the following URL
DataDirect Connect for JDBC driver
http://www.datadirect.com/products/jdbc/comparing_with_microsoft/index.ssp
Hope this helps. Please post a reply if the above solution works!
Thanks,
Nakshathram. -
Question about load Microsoft JDBC driver for Sql server 2000
Hello,
I have some problem while trying load the sqlserver2000 jdbc driver
My program is a third party application and it works with the other type 4 JDBC driver well. So I tried to use Microsoft SQL server 2000 JDBC driver instead.
I installed JDBC driver and set up the classpath.
My error message is:
"Driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' could not be loaded"
Is above message means that my classpath setup correctly but the application could not load the class or the application could not find the jar file which containes the driver class?
By the way, the third party application I was using to load this JDBC driver does not certified to use microsoft JDBC driver. But I don't think it matter?
Thanks for your help
Hui LuHello,
I have some problem while trying load the
sqlserver2000 jdbc driver
My program is a third party application and it works
with the other type 4 JDBC driver well. So I tried to
use Microsoft SQL server 2000 JDBC driver instead.
I installed JDBC driver and set up the classpath.
My error message is:
"Driver class
'com.microsoft.jdbc.sqlserver.SQLServerDriver' could
not be loaded"
That is an unusual message. Presumably you did not see "NoClassDefFoundError". If you see that it means the class could not be found.
Is above message means that my classpath setup
correctly but the application could not load the class
or the application could not find the jar file which
containes the driver class?
By the way, the third party application I was using to
load this JDBC driver does not certified to use
microsoft JDBC driver. But I don't think it matter?
It could. Perhaps the app expects a certain functional level and the driver doesn't support that. And so it bails with the message that you see.
Or it could mean that you have do something special because it has its own class path, and the driver is not in that. -
MS SQL Server 2000 and JDBC Driver Problem
I was wondering if you could help me. I installed Java 1.4.1 on my Win2K machine along with MS SQL Server 2000 JDBC Service Pack 1 drivers.
The drivers and JDK installed perfectly and I properly set my class path. Yet everytime I try to execute my code I get the: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver error.
Any idea why? Is it posisible that the JDBC drivers are not comaptible with Java 1.4? I also installed 1.3.1 and I get the same issue. Let me know if you have any insisghts. Much thanks.
[email protected]Those drivers are perfectly compatible with JDK 1.4.1. I've used them successfully.
CNF Exception ALWAYS means that the class loader can't find the JAR in the CLASSPATH. You said you "properly" set your CLASSPATH. Am I right in assuming that you mean a Win2K environment variable?
I think that's a bad idea. I don't have one on my machines at all.
I always set the CLASSPATH myself when I compile and run an app, to make sure that I always have exactly what I need.
If you're running Tomcat, it doesn't even look at the system CLASSPATH as far as I know. If you're using this in a Web app, but those JARs in your WEB-INF/lib directory and deploy your stuff as a WAR file. Tomcat will find it in the CLASSPATH for sure then.
Let me know if either of those suggestions hits the mark. If not, send more info and I'll try again. - MOD -
JDBC - MS SQL Server 2000 Driver
Do you need to have J2EE to run the MS downloaded SQL Server 2000 JDBC Driver? Currently have the J2SE installed with JDK 1.31_01 installed and keep getting errors where doesn't recognize a number of class objects. -- Thanks
Do you need to have J2EE to run the MS downloaded SQL
Server 2000 JDBC Driver? Currently have the J2SE
installed with JDK 1.31_01 installed and keep getting
errors where doesn't recognize a number of class
objects. -- ThanksI did not have any problems on windows 2000 with SQL 7, J2SE 1.4 Beta 3. BUT You will have to re-jar the files since there is a corrupted jar file in their driver. This corruption is not fatal, but causes exceptions to be loggued.
Did you load the driver with Class.forName ?
Maybe you are looking for
-
Jobs running under sys user name
Oracle 10.2.0.3 Enterprise Win2k3 Just upgraded to 10.2.0.3 ee from 10.1.0.4 standard. The jobs were entered via em and given the proper owner. em was logged in as sys. All jobs are running as user name sys. Can the user name be changed to the owner
-
Iphone 4 slow after IOS 8 upgrade
I've upgraded my phone to IOS 8.0.2 and I've noticed a substantial decrease in both performance and ability to use SIRI. Apps load incredibility slow and SIRI is painfully slow. At least 8 seconds to load, and then another 8 to 10 to get the ap
-
Software install in Windows 7 doesn't see mapped drives
I've looked through the related topics that came up when I started to write this, but I am not sure they answer my questions fully. I am trying to install software on a Windows 7 box as the Administrator. My mapped drives are fine, I can see them and
-
When I forward an e-mail, I get a long string of gobblygook that goes with it and I cannot figure out how to eliminate it without having to delete it every time I forward an e-mail. The following is only part of the string that I am talking about. Ho
-
TestStand close notification from a DLL
How can I get a close notification from TestStand to my loaded DLL? I would like to have a message/notification from TestStand that it is in progress of shutdown, before it does FreeLibrary() on my DLL. This is to ensure that I always do a clean exit