Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tutorial about the practical usage of the SQL 2011
#1
Respected Sir A.A,

i have little bit ambiguity in the SQL, that how can i build the database (tables) in it, please give me any tutorial about the practical usage of the SQL.Thaks
Reply
#2
Code:
Here is the code to create the table in database, you can modify it according to your needs. import java.sql.Connection; import java.sql.DataTruncation; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLWarning; import java.sql.Statement; public class Main { public static void main(String[] args) throws Exception { Connection conn = getConnection(); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); stmt.executeUpdate("create table survey (id int, name CHAR(5) );"); stmt.executeUpdate("INSERT INTO survey(id, name)VALUES(111, '123456789')"); // since there were no errors, commit conn.commit(); ResultSet rs = stmt.executeQuery("SELECT * FROM survey"); outputResultSet(rs); rs.close(); stmt.close(); conn.close(); } private static void outputResultSet(ResultSet rs) throws Exception { ResultSetMetaData rsMetaData = rs.getMetaData(); int numberOfColumns = rsMetaData.getColumnCount(); for (int i = 1; i < numberOfColumns + 1; i++) { String columnName = rsMetaData.getColumnName(i); System.out.print(columnName + " "); } System.out.println(); System.out.println("----------------------"); while (rs.next()) { for (int i = 1; i < numberOfColumns + 1; i++) { System.out.print(rs.getString(i) + " "); } System.out.println(); } } private static Connection getConnection() throws Exception { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:CourseDSN"; return DriverManager.getConnection(url); } }

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send image to client over a socket in java 2011 Vuhelper 1 3,678 04-21-2012, 02:11 AM
Last Post: hoailenpro
  double buffering in java 2011-12 Vuhelper 0 2,203 09-12-2011, 10:30 PM
Last Post: Vuhelper
  Using wait and notify? in java 2011-12 Vuhelper 0 2,131 09-12-2011, 10:29 PM
Last Post: Vuhelper
  text wrap in java 2011-12 Vuhelper 0 2,142 09-12-2011, 10:27 PM
Last Post: Vuhelper
  How find the data in ArrayList? 2011-12 Vuhelper 0 2,497 09-04-2011, 07:21 AM
Last Post: Vuhelper
  TableModelListener ERROR in Java 2011 Vuhelper 0 2,034 07-23-2011, 05:47 PM
Last Post: Vuhelper
  Exception Handling in Java 2011 Vuhelper 0 1,986 07-23-2011, 05:46 PM
Last Post: Vuhelper
  Getting the element of a vector in Java 2011 Vuhelper 0 1,888 07-23-2011, 05:45 PM
Last Post: Vuhelper
  program does not enter for loop in Java 2011 Vuhelper 0 2,089 07-23-2011, 05:44 PM
Last Post: Vuhelper
  Editor does NOT contain a main type in Java 2011 Vuhelper 0 4,121 07-23-2011, 05:43 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)