Ask your own question, for FREE!
Computer Science 18 Online
OpenStudy (anonymous):

Can anybody help me out with Java program

OpenStudy (konradzuse):

what is your problem?

OpenStudy (konradzuse):

For database connections you need to make sure the JDBC is connected with ODBC.

OpenStudy (konradzuse):

you need to post your file path into ODBC under "System files."

OpenStudy (konradzuse):

import java.sql.*; import java.io.*; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; class JdbcDemo1 { Connection con; Statement stmt; ResultSet rs; JdbcDemo1() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection( "Jdbc:Odbc:access", "",""); stmt = con.createStatement(); rs = stmt.executeQuery("SELECT * From Items"); while (rs.next()) { String d = rs.getString("Description"); String u = rs.getString("UPC code"); //int s = rs.getInt("age"); System.out.println("Description: "+d + " UPC Code: " + u); } //System.out.println(i); stmt.executeUpdate("INSERT INTO Items (Description, [UPC code]) VALUES ('Colombian', '101')"); } catch(SQLException e) { System.out.println("Hello World!"+e); } catch(ClassNotFoundException e) { System.out.println("purni"+e); } } } class JdbcDemo { public static void main(String args[]) { new JdbcDemo1(); } }

OpenStudy (anonymous):

k..

OpenStudy (konradzuse):

some of the code isn't needed, but this is basically what you need.

OpenStudy (konradzuse):

it needs to check the database exists, and you need SQL commands to process it.

OpenStudy (anonymous):

oh i am not getting the one u told reg odbc tat u told

OpenStudy (konradzuse):

?

OpenStudy (anonymous):

i have till now written the code which contains set of bean class and the managed beam class which performs the addition of 2 numbers.

OpenStudy (anonymous):

now I have the jsp file for user interface

OpenStudy (konradzuse):

hmmokay lets see.

OpenStudy (konradzuse):

jsp file? or jar?

OpenStudy (anonymous):

jsp file for user interface

OpenStudy (anonymous):

now i want create a command promt for user to enter those 2 numbers

OpenStudy (anonymous):

and result i want to desplay back in panel

OpenStudy (anonymous):

I know question is very basic... but we are not able make the interaction between user interface and java code written

OpenStudy (anonymous):

as we are new to this not able to understand most of your teminology used like odbc and all

OpenStudy (konradzuse):

you said you wanted a database...? For that you need the ODBC:JDBC which is Open Database Connectivity: Java Database Connectivity

OpenStudy (konradzuse):

Not sure why you ened JSP, this is for the web?

OpenStudy (konradzuse):

basically if you want to make a GUI you should use Swing.

OpenStudy (konradzuse):

JSP is for the web, so if you want that then go for it. I've never used JSp tho.

OpenStudy (anonymous):

Swing??

OpenStudy (konradzuse):

now you say command prompt you could throw up a dialog box to add 2 numbers together. Swing/AWT/FX are the names of the GUI Java types.

OpenStudy (konradzuse):

AWT is oldschool windows, SWing is newer and fancier, and FX is balling :).

OpenStudy (konradzuse):

Also why do you need beans?

OpenStudy (anonymous):

k... the thing is tat i am not able to form right quetion

OpenStudy (anonymous):

anyways i will tell my prob statement

OpenStudy (konradzuse):

can you post the code you have as well?

OpenStudy (anonymous):

package mBLogin; import toL.AddTo; import wrapperLogin.Add_Wrapper; public class AddMB { private Integer Int1; private Integer Int2; public Integer getInt1() { return Int1; } public void setInt1(Integer int1) { this.Int1 = int1; } public Integer getInt2() { return Int2; } public void setInt2(Integer int2) { this.Int2 = int2; } public String addInts() throws Exception{ AddTo addTO=new AddTo(); addTO.setInt1(this.getInt1()); addTO.setInt2(this.getInt2()); Add_Wrapper wrapper = new Add_Wrapper(); Integer Result = wrapper.addIntegers(addTO); System.out.println("The sum of the 2numbers is:"+Result); return "Success"; } }

OpenStudy (konradzuse):

It seems like your'e missing some code, and Idk what those imports are, or why they are needed.

OpenStudy (konradzuse):

YOu are on the right track, but basically you would want to throw up a dialog or some other sort of thing like a Jtextfield in which the user enters the value, and then you grab the value using Integer.parseInt(String);

OpenStudy (anonymous):

actually there are 3 seperate classes in whihc it is done

OpenStudy (anonymous):

may be our approach is wrong because we did not know how to start

OpenStudy (konradzuse):

I'll ask again, is this for the web, or for client side?

OpenStudy (konradzuse):

Jsp is for the web.

OpenStudy (konradzuse):

YOu could also make an applet.

OpenStudy (anonymous):

k... let me form the problem statement ,,, u can guide us how to proceed

OpenStudy (anonymous):

we have some stub api classes which performs addition ,substraction or some more operations.We want to create an user panel asking for the list of operations possible

OpenStudy (anonymous):

user can choose one of them in the user interface. So for instance he chooses addition. We should give panel interface asking for 2 inputs to enter

OpenStudy (konradzuse):

does he click a button or what?

OpenStudy (konradzuse):

and again is this web or client side?

OpenStudy (anonymous):

client side

OpenStudy (konradzuse):

ok so you dont' need JSp at all, nor do you need a bean.

OpenStudy (konradzuse):

Basically you would need to create the GUI itself(I personally like Netbeans because there is a gui form where you can build the gui components).

OpenStudy (anonymous):

no need of database also??

OpenStudy (konradzuse):

I don't think so, unless you are storing something into the fields....

OpenStudy (anonymous):

like result of operations and all

OpenStudy (konradzuse):

then you could pop up a dialog box asking them to input numbers, either 1 dialog per # or something like a ',' comma to delimeter.

OpenStudy (anonymous):

will there be some interface libraries between gui panel and java code

OpenStudy (konradzuse):

Just the normal java ones.

OpenStudy (konradzuse):

nothing fancy needed.

OpenStudy (konradzuse):

private javax.swing.JTextField C1; private javax.swing.JButton Calculate; private javax.swing.JLabel Cart;

OpenStudy (konradzuse):

are a few I used.

OpenStudy (anonymous):

do you any sample similar form done with u already.we will sue it as reference

OpenStudy (anonymous):

oh ok....

OpenStudy (konradzuse):

go download netbeans, and go check out their sample gui form.

OpenStudy (anonymous):

ok

OpenStudy (anonymous):

will downlaod and do check out... Thanks very much for support

OpenStudy (konradzuse):

np come back when you have some more questions.

OpenStudy (anonymous):

ya sure thanks

OpenStudy (konradzuse):

yup yup.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!