Board index » jbuilder » MS SQL Server

MS SQL Server


2004-02-26 06:16:37 AM
jbuilder8
Hello,
I'm a .NET Developer but unfortunately i have to write Java application this
time. I have got JBuilderX and now finding out. How i can connect my
application with MS SQL Server 2000 and tag column's with textboxes.
Thanks.
 
 

Re:MS SQL Server

In <403d1e88$ XXXX@XXXXX.COM >Azeem M. Suleman wrote:
Quote
Hello,

I'm a .NET Developer but unfortunately i have to write Java
application this time. I have got JBuilderX and now finding out. How i
can connect my application with MS SQL Server 2000 and tag column's
with textboxes.

Thanks.
You need to study JDBC.. (big topic, far too big to address here)
If you have specific questions about JDBC, fire away...
John..
--
=============================================
TeamB are volunteer helpers. Please DO NOT REPLY VIA EMAIL!
Post all questions and replies to this newsgroup ONLY
For papers on DataExpress, Applets, JSP, and Web Development go to:
www.microps.com/mps/papers.html
====================================================
 

Re:MS SQL Server

Quote
>I'm a .NET Developer but unfortunately i have to write Java
Welcome! I came from a VB background to Java and I haven't looked back.
Quote
>application this time. I have got JBuilderX and now finding out. How i
You got the cats meow of tools. JB is the defacto IDE for java. Like VS is
for C# and VB.
Quote
>can connect my application with MS SQL Server 2000 and tag column's
>with textboxes.
Java's a bit different from VB (not sure if that's where you're coming from,
but I know a bit about VB). It's been a while, but if I remember correctly,
you tell your VB program settings to connect to a specific db, then you can
drop txtboxes onto a form and link the form to the fields, correct? I think
you can do that with JB, but I haven't done that before myself. In what
I've done, it's more like C/C++ where you have to code all that stuff up
yourself using JDBC. It's not that hard, just a bit more work if you're
used to doing it the VB way.
Good luck.
 

{smallsort}

Re:MS SQL Server

Yes that i was looking for. ;). Can you give me any good url or reference
that can clear a good picture about db in Java. Like i have to connect MS
SQL Server, Oracle and IBM Unidata 5.x.
I found Oracle inside JB and download MS SQL Server jar file from Microsoft
website. But stuck as VS make u dummy coder :(
Thanks.
"Flip" <[remove] XXXX@XXXXX.COM >wrote in message
Quote
>>I'm a .NET Developer but unfortunately i have to write Java
Welcome! I came from a VB background to Java and I haven't looked back.

>>application this time. I have got JBuilderX and now finding out. How i
You got the cats meow of tools. JB is the defacto IDE for java. Like VS
is
for C# and VB.

>>can connect my application with MS SQL Server 2000 and tag column's
>>with textboxes.
Java's a bit different from VB (not sure if that's where you're coming
from,
but I know a bit about VB). It's been a while, but if I remember
correctly,
you tell your VB program settings to connect to a specific db, then you
can
drop txtboxes onto a form and link the form to the fields, correct? I
think
you can do that with JB, but I haven't done that before myself. In what
I've done, it's more like C/C++ where you have to code all that stuff up
yourself using JDBC. It's not that hard, just a bit more work if you're
used to doing it the VB way.

Good luck.


 

Re:MS SQL Server

Azeem M. Suleman wrote:
Quote
Yes that i was looking for. ;). Can you give me any good url or reference
that can clear a good picture about db in Java. Like i have to connect MS
SQL Server, Oracle and IBM Unidata 5.x.

I found Oracle inside JB and download MS SQL Server jar file from Microsoft
website. But stuck as VS make u dummy coder :(
One obvious link is JBuilder's built-in Help system:
"Developing Database Applications", especially the
section in the Guide on "Connecting to a database".
The Java site has lots of tutorials. Look for
the one on JDBC. The quickest way to get there is
to go to the JBuilder Help>Index tab, type JDBC API
and click the first link on that page.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:MS SQL Server

Thanks a million
"Paul Furbacher [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
Azeem M. Suleman wrote:

>Yes that i was looking for. ;). Can you give me any good url or
reference
>that can clear a good picture about db in Java. Like i have to connect
MS
>SQL Server, Oracle and IBM Unidata 5.x.
>
>I found Oracle inside JB and download MS SQL Server jar file from
Microsoft
>website. But stuck as VS make u dummy coder :(

One obvious link is JBuilder's built-in Help system:
"Developing Database Applications", especially the
section in the Guide on "Connecting to a database".

The Java site has lots of tutorials. Look for
the one on JDBC. The quickest way to get there is
to go to the JBuilder Help>Index tab, type JDBC API
and click the first link on that page.


--


Paul Furbacher (TeamB)

Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html

Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html

Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:MS SQL Server

Quote
I've done, it's more like C/C++ where you have to code all that stuff up
yourself using JDBC. It's not that hard, just a bit more work if you're
used to doing it the VB way.

this is some pseudo-code for connecting java with any database:
import java.sql.*;
/** Configuration string for initializing the database connection. */
private final String BASE = "jdbc:JSQLConnect://";
/** Configuration string for initializing the database connection. */
private final String DATABASE = "/database=";
/** Configuration string for finding the database driver class. */
private final String CLASS = "com.jdbc.mssql.Driver"; //this is just an example, find a good driver, the best are Type 4
/**
* Attempts to establish a connection to the given database URL.
* <p>
* It uses a special driver to create the connection
* <p>
*
* @param dbHostName the name of the database host.
* @param dbName the bridgh with the data base.
* @param user the user login.
* @param password the user password.
* @throws SQLException when a connection can not be made.
* @throws ClassNotFoundException when the default database driver can not be found.
*/
public void connectDB(String dbHostName, String dbName, String user,
String password) throws SQLException, ClassNotFoundException {
Class.forName(CLASS);
String sConnect = BASE + dbHostName + DATABASE + dbName;
Properties info = new Properties();
info.put("user", user);
info.put("password", password);
conn = DriverManager.getConnection(sConnect, info);
PreparedStatement pstmt = conn.prepareStatement(getQuery());
ResultSet rst = pstmt.executeQuery();
//iterates over the rows on the resultset
while (rst.next())
; //do your stuff
//VERY IMPORTANT close all 3
rst.close();
pstmt.close();
conn.close();
}