Sunday, June 19, 2016

JDBC

/* * (#) DataBaseDemo.java */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.DriverManager; public class data { public static void main(String[] args) throws SQLException { // Connection con = DriverManager.getConnection ("jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};dbq=balan.mdb;"); Connection con = DriverManager.getConnection("jdbc:odbc:balanew"); Statement stmt = con.createStatement(); ResultSet rs; stmt.executeUpdate("create table temp(name varchar(10), age number)"); stmt.executeUpdate("insert into temp values ('Sakthi', 22.5)"); stmt.executeUpdate("insert into temp values ('Balaji', 23.5)"); // stmt.executeUpdate("delete from temp"); rs = stmt.executeQuery("select * from temp"); while(rs.next()) { System.out.println(rs.getString(1)); System.out.println(rs.getInt(2)); } } }/* * (#) DataBaseDemo.java */ import java.sql.Connection; import java.sql.Statement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.DriverManager; public class DataBaseDemo { public static void main(String[] args) throws SQLException { Connection con = DriverManager.getConnection ("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};dbq=New.mdb;"); // Connection con = DriverManager.getConnection("jdbc:odbc:Balaji"); Statement stmt = con.createStatement(); ResultSet rs; // stmt.executeUpdate("create table temp(name varchar(10), age number)"); stmt.executeUpdate("insert into temp values ('Sakthi', 22.5)"); stmt.executeUpdate("insert into temp values ('Balaji', 23.5)"); // stmt.executeUpdate("delete from temp"); rs = stmt.executeQuery("select * from temp"); while(rs.next()) { System.out.println(rs.getString(1)); System.out.println(rs.getInt(2)); } } }import java.awt.*; import java.applet.*; /* <applet code="simpleapplet" width=200 height=60></applet>*/ public class simpleapplet extends Applet { public void paint(Graphics g) { g.drawString("sakthivel",30,20); } }import java.io.*; class nex { public static void main(String ss[]) throws IOException { Runtime r =Runtime.getRuntime(); Process p=null; p=r.exec("notepad"); p=r.exec("control"); } } import java.awt.*; import java.applet.*; /* <applet code="simpleapplet" width=200 height=60></applet>*/ public class simpleapplet extends Applet { public void paint(Graphics g) { g.drawString("sakthivel",30,20); } }import java.io.*; class str { public static void main (String ss[]) { String s1="one"; String s2="sakthivel".toUpperCase(); System.out.println(s2); } }

No comments:

Post a Comment

உப்பு மாங்காய்

சுருக்குப்பை கிழவி. சுருக்கங்கள் சூழ் கிழவி. பார்க்கும் போதெல்லாம் கூடையுடனே குடியிருப்பாள். கூடை நிறைய குட்டி குட்டி மாங்காய்கள். வெட்டிக்க...