first establish the connection
step 1: import sql package(import java.sql.*;)
step 2: initiate driver:
step 3:creat connection:
Connection conn = DriverManager.getConnection(url,username,password);
url --> "jdbc:odbc:DSN Name"
DSN(data source name).
user -->user name of the server
password -->password of the server
this 3 parameters are String.
step 4:create statement:
Statement stmt = conn.createStatement();
step 5:use result set to access the records in the table
ResultSet rset = stmt.executeQuery("SELECT * FROM Table_Nmae");
step 6:this code is used to display the value of the Table_Name from first to last row
getString(1) -->means first column(field) value of each row
this are the example for list the database values.if you want to list it as dropdown by using "JComboBox" class its in java swing(jdk1.5).
JComboBox object_Name = new JComboBox();
we use object_Name.addItem(rset.getString(1)); to System.out.println(rset.getString(1));
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...