Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Connection dbconnect()
- {
- Connection conn = null;
- String url = "jdbc:mysql://localhost:3306/";
- String db = "gup";
- String driver = "com.mysql.jdbc.Driver";
- String user = "root";
- String pass = "";
- try{
- Class.forName(driver);
- conn = DriverManager.getConnection(url + db, user, pass);
- if(conn == null){
- System.out.println("Connection is not established");
- }
- return conn ;
- }
- catch(Exception e)
- {
- System.out.println(e);
- }
- return null ;
- }
- public void insertfile(String fpath,String fname,String fext)
- {
- PreparedStatement pstmt = null;
- // Connection conn = null ;
- dbConnection dbcon = new dbConnection();
- pstmt = (PreparedStatement) dbcon.dbconnect();
- //Create the statement object
- String sql = "insert into FileDetails (folder_path,file_name,file_extension)" + "values (?,?,?)";
- try
- {
- //ResultSet rs = pstmt.executeQuery(sql);
- pstmt.setString(1, fpath);
- pstmt.setString(2, fname);
- pstmt.setString(3, fext);
- pstmt.executeQuery(sql);
- }
- catch(SQLException se)
- {
- System.out.println(se);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement