Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1219
| Newsgroups | comp.lang.java.help |
|---|---|
| From | Linus Flustillbe <admin@nacs.dyndns-office.com> |
| Subject | Re: Can a ResultSet be passed back to a main program |
| References | <4e92594f$0$14660$9a566e8b@news.aliant.net> <j6uvcp$uh2$2@dont-email.me> |
| Date | 2011-10-10 17:06 +0000 |
| Message-ID | <4e932629$0$13642$9a566e8b@news.aliant.net> (permalink) |
On 2011-10-10, markspace <-@> wrote:
> On 10/9/2011 7:32 PM, Linus Flustillbe wrote:
>
>> 1. Create a class that
>> a) creates a connection to an oracle database
>> b) run a simple query to get a result set
>> c) pass the result set back to a calling program.
>
>
> Most of this information can be found in the Java tutorials. Are you
> using those?
>
> http://download.oracle.com/javase/tutorial/jdbc/
>
I actually figured it out on my own without the aid of the tutorials or
JLS. Google is my friend.. :-)
import java.sql.*;
import mainClasses.*;
public class connectionTest {
public static void main(String[] args)
throws ClassNotFoundException, SQLException
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String tableName="LU_MEDIA_USAGE";
TableConnect myConnection = new TableConnect();
Statement stmt = myConnection.getStatement();
ResultSet rset = myConnection.GetResultSet(stmt, tableName);
ResultSetMetaData rsetmd = rset.getMetaData();
while (rset.next()) {
for (int i=1;i<=rsetmd.getColumnCount();i++)
{
System.out.print (rset.getString(i) + " " );
if ( i == rsetmd.getColumnCount())
{
System.out.println("<--->");
}
}
}
stmt.close();
}
}
Output
CL Computer Language <--->
COM Comedy <--->
CS Computer Software <--->
DRA Drama <--->
HIS History <--->
HOR Horror <--->
NF Non-Fiction <--->
OPS Operating System <--->
REC Recreational/Gaming <--->
ROM Romance <--->
SF Science Fiction <--->
THR Thriller <--->
TR Theological Resource <--->
-----------------------------------------------
I wanted to just show the values of each column so I googled and found
out about the ResultSetMetaData and used the javadocs to find the
method on the result set to create the metadata. Interesting stuff,
this jdbc stuff... I can't wait until I actually start designing and
coding the GUI that I plan on. I'm just learning about the nuts and
bolts right now.
FYI - I have my own local copy of the tutorials in case oracle is ever
down as well as the API. I haven't gotten around to the JLS yet but
will shortly.
--
****************************************************************
* Usenet Impovement Project http://nacs.dyndns-office.com/usenet
****************************************************************
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar
Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 02:32 +0000
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 02:37 +0000
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 06:28 +0000
Re: Can a ResultSet be passed back to a main program Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-10-10 14:26 -0300
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 19:21 +0000
Re: Can a ResultSet be passed back to a main program markspace <-@.> - 2011-10-10 07:27 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 17:06 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-10 10:10 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-10 19:23 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-10 14:26 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-11 00:43 +0000
Re: Can a ResultSet be passed back to a main program Roedy Green <see_website@mindprod.com.invalid> - 2011-10-12 09:52 -0700
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-12 10:28 -0700
Re: Can a ResultSet be passed back to a main program Linus Flustillbe <admin@nacs.dyndns-office.com> - 2011-10-13 01:24 +0000
Re: Can a ResultSet be passed back to a main program Lew <lewbloch@gmail.com> - 2011-10-12 18:55 -0700
csiph-web