Can anybody help me out with Java program
what is your problem?
For database connections you need to make sure the JDBC is connected with ODBC.
you need to post your file path into ODBC under "System files."
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(); } }
k..
some of the code isn't needed, but this is basically what you need.
it needs to check the database exists, and you need SQL commands to process it.
oh i am not getting the one u told reg odbc tat u told
?
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.
now I have the jsp file for user interface
hmmokay lets see.
jsp file? or jar?
jsp file for user interface
now i want create a command promt for user to enter those 2 numbers
and result i want to desplay back in panel
I know question is very basic... but we are not able make the interaction between user interface and java code written
as we are new to this not able to understand most of your teminology used like odbc and all
you said you wanted a database...? For that you need the ODBC:JDBC which is Open Database Connectivity: Java Database Connectivity
Not sure why you ened JSP, this is for the web?
basically if you want to make a GUI you should use Swing.
JSP is for the web, so if you want that then go for it. I've never used JSp tho.
Swing??
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.
AWT is oldschool windows, SWing is newer and fancier, and FX is balling :).
Also why do you need beans?
k... the thing is tat i am not able to form right quetion
anyways i will tell my prob statement
can you post the code you have as well?
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"; } }
It seems like your'e missing some code, and Idk what those imports are, or why they are needed.
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);
actually there are 3 seperate classes in whihc it is done
may be our approach is wrong because we did not know how to start
I'll ask again, is this for the web, or for client side?
Jsp is for the web.
YOu could also make an applet.
k... let me form the problem statement ,,, u can guide us how to proceed
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
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
does he click a button or what?
and again is this web or client side?
client side
ok so you dont' need JSp at all, nor do you need a bean.
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).
no need of database also??
I don't think so, unless you are storing something into the fields....
like result of operations and all
then you could pop up a dialog box asking them to input numbers, either 1 dialog per # or something like a ',' comma to delimeter.
will there be some interface libraries between gui panel and java code
Just the normal java ones.
nothing fancy needed.
private javax.swing.JTextField C1; private javax.swing.JButton Calculate; private javax.swing.JLabel Cart;
are a few I used.
do you any sample similar form done with u already.we will sue it as reference
oh ok....
go download netbeans, and go check out their sample gui form.
ok
will downlaod and do check out... Thanks very much for support
np come back when you have some more questions.
ya sure thanks
yup yup.
Join our real-time social learning platform and learn together with your friends!