Jump to content

mk_gunnerz

Members
  • Content Count

    273
  • Joined

  • Last visited

Community Reputation

0 Normal

About mk_gunnerz

  • Rank
    Ahli

Contact Methods

  • AIM
    amik ni..fire in the hall...TEBABO�
  • ICQ
    0

Profile Information

  • Gender
    Female
  • Location
    bangi

Previous Fields

  • Nama lain
    -
  1. salam.saya dalam dilema nak pergi atau tidak program Industrial skill enhancement program(insep) untuk graduan yang tak keja lagi di PSDC kerana saya ni masih menunggu kerja.   ada sesiapa yang pernah join program ini?   penginapan tidak disediakan dan itu jugak agak merunsingkan saya untuk tinggal di kuantan.   kursus yang ditawarkan untuk pelajar it ialah data com dan fiber optic.tapi saya taktau minat saya dah kemana sebab saya tak minat it dan lemah programming dan takut bila dah pergi kursus rasa nak berhenti.   harap sesiapa dapat bantu saya . pendaftaran mungkin 5 februari 2014 di PSDC semambu kuantan.
  2. salam..saya de masalah nak connect dengan database.saya implement guna jdk1.6,mysql xamp,jdbc..masalahnya bila run,keluar not suitable driver found for jdbc..saya dah cba install jdbc driver n set classpath,tp tetap xberjaya.mohon bantuan.. import java.util.*; import java.io.*; import java.sql.*; import java.lang.*; public class function{ public static String filename; public static Scanner input; public static String[] data; public void uploadSQL() { System.out.println("======================================="); System.out.println("\tUpload to SQL :"+filename); System.out.println("======================================="); try{ //Connection conn = null; Statement stmt = null; //prepareStatement = null; ResultSet rs = null; //load JDBC Driver /* try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); System.out.println("Driver loaded"); } catch (Exception ex) { }*/ //Establish a connection String url = "jdbc:mysql://localhost/company?user=root&password=tiger"; Connection conn = DriverManager.getConnection(url,"root","tiger"); //conn =DriverManager.getConnection("jdbc:mysql://localhost/mydatabase?"+"userName=root&password=tiger"); System.out.println("Database connected"); //Create statement stmt = conn.createStatement(); rs = stmt.executeQuery("INSERT INTO student(name,matric,gender,state,faculty)"+ "values(?,?,?,?,?)"); try{ FileReader fr = new FileReader(new File(filename)); BufferedReader br = new BufferedReader(fr); String value; while((value = br.readLine()) != null){ String[] column = value.split(","); for(int i = 0; i<column.length; i++){ if(!column[i].trim().equals("")) { rs = stmt.executeQuery(column[i]); //System.out.println(">>"+column[i]); } } } br.close(); } catch(IOException e){ e.printStackTrace(); System.out.println("File not found!"); } System.out.println("successful insert data"); System.out.println("All data are inserted in the database table"); //Close the connection conn.close(); } catch(SQLException ex){ System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); //System.out.println("Not found"); } } public void readFromFile(){ try{ System.out.println(); System.out.println("====================================================="); System.out.println("\tWELCOME TO JAVA APPLICATION"); System.out.println("====================================================="); System.out.println(); System.out.print("Enter CSV file name:\t"); //System.out.println(); Scanner readkey = new Scanner(System.in); filename = readkey.next(); //use buffering FileInputStream file = new FileInputStream(filename); DataInputStream data = new DataInputStream(file); BufferedReader input = new BufferedReader(new InputStreamReader(data)); System.out.println("File Found!"); data.close(); file.close(); input.close(); } catch(IOException e){ e.printStackTrace(); System.out.println("File not found!"); } } }
×
×
  • Create New...