Advertisement
ASP_Volume3 String Manipulation #46309

Generate Random Numbers, letters and symbols

Generates a random string of numbers, letters and symbols, then places it in a string. Once this has been done 3399 times (or times set by user) it writes the string to a file under the variable filelocation

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
Upload
Upload
/*
 programmer name:Muthukumar and Deva
steps for creating data source
control panel->Administrative Tools->Data Sources (ODBC)->
select user DSN tab then click add button
select Microsoft ODBC driver for Oracle
fill your data source (here it is patni)
and username and servername(oracle)
click of
Limitations:
   This code only works in Windows platform
*/
import java.sql.*;
class Connectivity
{
  Connection conn;
 Statement stmt;
 PreparedStatement s1;
 void connect()
 {  
  try
  {
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
   
   conn = DriverManager.getConnection("jdbc:odbc:patni","devarajan","devarajan");
   // patni--->datasource,devarajan---->username,devarajan->password
  }
  
  catch(Exception e)
  {
   System.out.println("ee"+e.getMessage());
   
  }
    
 } 
 
 void insertData(String nme,String roll)
 {
  try
  {
   s1=conn.prepareStatement("insert into stu values(?,?)");
    s1.setString(1,nme);
    s1.setString(2,roll);    
    s1.executeUpdate();    
    System.out.println("Record inserted"); 
    s1.close();
  }
  catch(Exception s)
  {
   System.out.println(s.getMessage());
  }
   
 }
 
  void updateData()
 {
  try
  {      
    stmt=conn.createStatement();    
    int i=stmt.executeUpdate("update stu set name='muthukumar4u' where roll='05mx23'" );    
    System.out.println("\t\t\t"+i +" record updated in updation funtion");     
    stmt.close();  
  }
  
  catch(Exception s)  {
   System.out.println(s.getMessage());
  }
   
 }
 void deleteData()
 {
  try
  {
    stmt=conn.createStatement(); 
    
    int i=stmt.executeUpdate("delete from stu where name='muthukumar4u'" );
    System.out.println(i+" records Deleted");       
    stmt.close();
  
  
  
  }  
  catch(Exception s)  {
   System.out.println(s.getMessage());
  }
  
 }
 void displayData()
 {
  try
  {
    stmt=conn.createStatement(); 
    ResultSet rs = stmt.executeQuery("select * from stu"); 
    System.out.println("The table contains:");
    while(rs.next())
    {
     System.out.println("Name:"+rs.getString("name"));
     System.out.print("  Roll no:"+rs.getString("roll"));     
    }
  }
  catch(Exception e)
  {
   System.out.println(e.getMessage());
  
  }
 }
}
public class JavatoOracle 
{
 
public static void main(String args[])
{
 Connectivity c=new Connectivity();
  c.connect();
  c.insertData("muthukumar", "05mx23");
  c.displayData();
  c.updateData();
  c.displayData();
  c.deleteData();
  c.displayData();
}
}
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine