Re: Moving Java Applet from Sun Environment to Windows..



On Aug 20, 12:52 pm, crab....@xxxxxxxxx wrote:
Folks,

I'm not worried about the SQL queries themselves because I can fix
those. My biggest issue is changing the connection string to connect
to MS SQL, instead of Oracle.

I just started a new thread from what's the the original JAVA file,
but here's a copy below in case anyone can help.

==================================

Need some help.....

Below is what I currently have that's written in JAVA to connect to
Oracle, but I need to change it to connect to MS SQL.

===========

private void dbInit()
{
dbUrl = "jdbc:oracle:thin:@" + paramServerIP + ":3500:" +
paramDbSID;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(Exception eDriver)
{
failedDialog("Driver failed!", eDriver.getMessage());
}
}

private void dbOpen()
{
if(paramServerIP.indexOf("datadev") >= 0)
dbPswd = "test_pass";
else
dbPswd = "web_pass";
try
{
dbCon = DriverManager.getConnection(dbUrl, paramDbUserStr,
dbPswd);
dbStmt = dbCon.createStatement();
dbStmt.setEscapeProcessing(true);
}
catch(Exception eDbOpen)
{
failedDialog("Failed to open db connection!",
eDbOpen.getMessage());
}
}

private void dbClose()
{
try
{
dbStmt.close();
dbCon.close();
}
catch(Exception eDbClose)
{
failedDialog("Failed to close db connection!",
eDbClose.getMessage());
}
}
=========

Can someone tell what what I need to change? I need to change it to
connect a Database named datadev on a MS SQL 2000 server. Where do I
put the below info?

"jdbc:odbc:DRIVER={SQL
Server};Database="DATADEV";Server=VS032.INTERNAL.COM:3553;",
"web_user", "password"

Here's info that might be more clear then the above:

Server: VS032.INTERNAL.COM
Port: 3553
Database: DATADEV
User ID: web_user
Password: password

Sorry to ask, but I'm not a JAVA developer and was tasked to move a
web page from a UNIX platform to a Windows setup.

===========================

It's probably something simple that most of you could do with your
eyes closed, but for me, Java is learning Chinese.

Thanks!!

Best option would be to pull these settings out of your code, and put
them either in properties file, or have your main class read it as
system properties (via -Dname=value).

You'd need a Connection URL, UserID, password and the jdbc driver
class name for any JDBC connection to any db, so people normally
externalize these.

Then, you will need to download MS-SQL pure JDBC driver, or you can
use the JDBC-ODBC bridge (I would not recommend it though). For the
pure JDBC driver, either you can use the one from Microsoft, or an
open source one from JTDS. (http://jtds.sourceforge.net/).

In case of jTDS, the driver class name would be
"net.sourceforge.jtds.jdbc.Driver" and connection URL will be
jdbc:jtds:sqlserver://vs032.internal.com:3553/DATADEV.

Refer to jTDS site on FAQ and documentation.

-cheers,
Manish


.



Relevant Pages

  • Re: connecting to a database
    ... so I'm attempting to code it up in java. ... I have no idea how to set up a connection. ... connection to an Access Database that they would be willing to post. ... sql. ...
    (comp.lang.java.programmer)
  • Re: connecting to a database
    ... I have no idea how to set up a connection. ... connection to an Access Database that they would be willing to post. ... throws java. ... sql. ...
    (comp.lang.java.programmer)
  • JDBC for sql server: delays experienced when using Connection.prepareCall()
    ... I have been doing some performance tests of the MS jdbc driver for sql ... sql server instance). ... prepareCall(on the same Connection) to generate a different ...
    (comp.lang.java.databases)
  • Re: Moving Java Applet from Sun Environment to Windows..
    ... Oracle, but I need to change it to connect to MS SQL. ... You'd need a Connection URL, UserID, password and the jdbc driver ... Then, you will need to download MS-SQL pure JDBC driver, or you can ...
    (comp.lang.java.programmer)
  • Re: Possible Type Conversion Defect
    ... I'm developing a large application using SAP Web Application Server ... with JDBC Driver Beta 2 for SQL Server 2005 and I'm getting the SAME ... There's any solution or I must change my strategy to don't choice SQL ... a JDBC driver attempts to convert the underlying data to the Java ...
    (microsoft.public.sqlserver.jdbcdriver)