用JAVA往数据库写入数据,既没有抛出异常,也没有写入成功,求高手指教???急啊!
importjava.sql.*;importjava.io.*;importjava.util.*;publicclasstext{publicstaticvoidwr...
import java.sql.*;
import java.io.*;
import java.util.*;
public class text{
public static void writers(String a,String b,String c) throws Exception{
String sql="insert into Table3 values('"+a+"','"+b+"','"+c+"')";
try{
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
conn.prepareStatement(sql);
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String args[]) throws Exception{
text.writers("yunchen",null,null);
System.out.println("shuruok");
}
} 展开
import java.io.*;
import java.util.*;
public class text{
public static void writers(String a,String b,String c) throws Exception{
String sql="insert into Table3 values('"+a+"','"+b+"','"+c+"')";
try{
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
conn.prepareStatement(sql);
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String args[]) throws Exception{
text.writers("yunchen",null,null);
System.out.println("shuruok");
}
} 展开
展开全部
Statement haha = conn.prepareStatement(sql);
haha.updatee....();//忘记了
haha.updatee....();//忘记了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.sql.*;
import java.io.*;
import java.util.*;
public class text{
public static void writers(String a,String b,String c) throws Exception{
PreparedStatement pstmt = null;
String sql="insert into Table3 values('"+a+"','"+b+"','"+c+"')";
try{
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
pstmt= conn.prepareStatement(sql);
pstmt.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String args[]) throws Exception{
text.writers("yunchen",null,null);
System.out.println("shuruok");
}
}
import java.io.*;
import java.util.*;
public class text{
public static void writers(String a,String b,String c) throws Exception{
PreparedStatement pstmt = null;
String sql="insert into Table3 values('"+a+"','"+b+"','"+c+"')";
try{
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
pstmt= conn.prepareStatement(sql);
pstmt.executeUpdate();
}catch(SQLException e){
e.printStackTrace();
}
}
public static void main(String args[]) throws Exception{
text.writers("yunchen",null,null);
System.out.println("shuruok");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
try{
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
Statement st=con.createStatement();
int a=st.executeUpdate(sql);
if(a>0){
System.out.println("执行成功");}
}catch(SQLException e){
e.printStackTrace();
}
Connection conn;
conn=DriverManager.getConnection("jdbc:odbc:zhouyun");
Statement st=con.createStatement();
int a=st.executeUpdate(sql);
if(a>0){
System.out.println("执行成功");}
}catch(SQLException e){
e.printStackTrace();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询