Notenougharguments.Usage:javaBase64-e|-dinputfileoutputfilepublicstaticvoidmain(Stringargs[])throwsException{Stringurl="jdbc:mysql://localhost:3306/dbtest";//localhost一般...
Not enough arguments.
Usage: java Base64 -e|-d inputfile outputfile
public static void main(String args[]) throws Exception
{
String url = "jdbc:mysql://localhost:3306/dbtest";
//localhost一般为自己的Ip或者是127.0.0.1,1433为mysql的装机时
//的端口名 jsp为要连接的数据库
String sql = "select * from yonghu";
//要执行的sql语句
//加载驱动
Class.forName("com.microsoft.sql.sqlserver.SQLServerDriver");
//就是上面下载的那个文件 是能够解压的要能够按顺序找
//到SQLServerDriver
//获得数据库连接
Connection con = DriverManager.getConnection(url, "root", "123");
//test为mysql的用户名 123 为密码
//如果不知道怎么设置mysql用户名和密码 参照下面
/*增加一个管理员帐户:grant all on *.* to user@localhost identified by "password";*/
//创建语句
Statement stmt = con.createStatement();
//执行SQL命令
stmt.executeUpdate(sql);
}
}
目的是为了实现java连接mysql
这个是从网上找的例子,具体我也不是很清楚
展开