Sir one big problem I took 4 inputs like id, name,city, salary then I taken user input and run the program two user input like name and city compiler asking at a same time and taking only one input for two values what should I do sir please reply me
scanner does not accept value after space.. to take input which has space for eg.: address ..we use bufferedReader.. it helps to a accept multiple words as input
#The below program is of my this video #I am getting a problem in setting Email_ID. Please, help me out in this program. #I can't under standing where I am doing wrong! import java.io.BufferedReader; import java.io.InputStreamReader; import java .sql.*; public class Insert2 {
public static void main(String[] args)throws Exception { //Loading driver Class.forName("com.mysql.cj.jdbc.Driver"); //Establishing Connection String url = "jdbc:mysql://localhost:3306/new"; String username = "root"; String password = "K!sl@y07"; Connection con = DriverManager.getConnection(url, username, password); if(con.isClosed()){ System.out.println("Connection is closed..."); }else{ System.out.println("Connection established successfully..."); } //Creating Query String InsertValue = "insert into Bob(EName, City, State, Mobile, Email_ID) values (?,?,?,?,?)";
//Creating a statement PreparedStatement st = con.prepareStatement(InsertValue); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Name : "); String name=br.readLine(); System.out.println("Enter City : "); String city=br.readLine(); System.out.println("Enter State : "); String state=br.readLine(); System.out.println("Enter Mobile number : "); Long mobile=(long) br.read(); System.out.println("Enter Email-ID : "); String email=br.readLine(); st.setString(1, name); st.setString(2, city); st.setString(3, state); st.setLong(4, mobile); st.setString(5, email); //Executing Statement st.executeUpdate(); System.out.println("Value Inserted Successfully..."); con.close();
}
} #The below program is of your previous video import java.sql.*; class Insert{ public static void main(String[] args){ try{ //load the driver Class.forName("com.mysql.cj.jdbc.Driver"); String url = "jdbc:mysql://localhost:3306/new"; String username = "root"; String password = "K!sl@y07"; Connection con = DriverManager.getConnection(url, username, password); if(con.isClosed()){ System.out.println("Connection is closed..."); }else{ System.out.println("Connection established successfully..."); } // create a query String CreateTable = "create table Bob(EID int(5) primary key auto_increment, EName Varchar(40) Not Null, City Varchar(15) Not Null, State Varchar(10) Not Null, Mobile int(15) Not Null, Email_ID Varchar(50))";
//Create a statement Statement st = con.createStatement(); st.executeUpdate(CreateTable); System.out.println("Table created in database successfully..."); con.close();
Even today after 3-4 yrs your content is the best, probably people back in 2020 didnt read ao much of all this. You are awesome, excellent, really.
Dont know why there are very less number of ppl who have subscribed this masterpiece.. Excellent content..
Helpful..🤝
Easy and crisp.... Thanks Durgesh.
very helpful and easy to learn and understand
thank you So much bro.......!
You r doing great job brother, wish u all the best.
thanks again for making so awesome video ...your way of teaching is just awesome Bhai
Sir one big problem I took 4 inputs like id, name,city, salary then I taken user input and run the program two user input like name and city compiler asking at a same time and taking only one input for two values what should I do sir please reply me
can we take input By scanner class also?
nice explanation!!!!!!!!!!!!!!!!!!!
Thanks bro so helpful
hi, can you share link of your video where u have explained how to install mysql? I am facing issue with installation
What if we use for loop for taking multiple value. I tried this with given example but getting wrong output i don't know why
Awesome 🔥
how to take the integer data dynamically?
wow i first time heared about bufferedreader instead of scanner class
Why do we use bufferdreader can we use scanner class aswell for asking name and city name???
yes both works , buffer reader is just faster than scanner
Too nice
great sir
Bro why used bufferreader instead of scanner can any one tell me your response will help me thanx in advance
scanner does not accept value after space.. to take input which has space for eg.: address ..we use bufferedReader.. it helps to a accept multiple words as input
@@dishagangurde3943 ohh thanx
@@dishagangurde3943 hey isme hum hmara java program kaise dalte hai database me ye to sirf create table kya hai smj nhi aa rha plz bato
To accept values after space use
Scanner sc = new Scanner(System.in);
// For line including space
sc.nextLine();
//For single word use
sc.next();
Scanner is better than buffer reader.
I read one article if we compare this two things memory could be save by using scanner class.
bro setString method takes two argument one is index onterone is String if incase having two more columns what to do
Hi, can you please show how can we perform the inserting to table with dynamic input using Postman.
Ok
Umm can anyone tell me what will be the data type for insertion of datetime datatype in java
InputStreamReader ka use kya hota h?
👌👌👍
Bhai I am getting more than 12 errors after copying same to same .what can I do
cleared..
null values inserted in database instead of actual values?? plz help
Yes u can do disha
Dynamic insert nahi ho raha hai
#The below program is of my this video
#I am getting a problem in setting Email_ID. Please, help me out in this program.
#I can't under standing where I am doing wrong!
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java .sql.*;
public class Insert2 {
public static void main(String[] args)throws Exception {
//Loading driver
Class.forName("com.mysql.cj.jdbc.Driver");
//Establishing Connection
String url = "jdbc:mysql://localhost:3306/new";
String username = "root";
String password = "K!sl@y07";
Connection con = DriverManager.getConnection(url, username, password);
if(con.isClosed()){
System.out.println("Connection is closed...");
}else{
System.out.println("Connection established successfully...");
}
//Creating Query
String InsertValue = "insert into Bob(EName, City, State, Mobile, Email_ID) values (?,?,?,?,?)";
//Creating a statement
PreparedStatement st = con.prepareStatement(InsertValue);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Name : ");
String name=br.readLine();
System.out.println("Enter City : ");
String city=br.readLine();
System.out.println("Enter State : ");
String state=br.readLine();
System.out.println("Enter Mobile number : ");
Long mobile=(long) br.read();
System.out.println("Enter Email-ID : ");
String email=br.readLine();
st.setString(1, name);
st.setString(2, city);
st.setString(3, state);
st.setLong(4, mobile);
st.setString(5, email);
//Executing Statement
st.executeUpdate();
System.out.println("Value Inserted Successfully...");
con.close();
}
}
#The below program is of your previous video
import java.sql.*;
class Insert{
public static void main(String[] args){
try{
//load the driver
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/new";
String username = "root";
String password = "K!sl@y07";
Connection con = DriverManager.getConnection(url, username, password);
if(con.isClosed()){
System.out.println("Connection is closed...");
}else{
System.out.println("Connection established successfully...");
}
// create a query
String CreateTable = "create table Bob(EID int(5) primary key auto_increment, EName Varchar(40) Not Null, City Varchar(15) Not Null, State Varchar(10) Not Null, Mobile int(15) Not Null, Email_ID Varchar(50))";
//Create a statement
Statement st = con.createStatement();
st.executeUpdate(CreateTable);
System.out.println("Table created in database successfully...");
con.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
very helpful and easy to learn and understand
thank you So much bro.......!