yunx li 4 years ago
commit 44d529a07a

@ -60,6 +60,8 @@ public class PlateRecoTest {
String col=color.desc;
System.err.println("识别到的车牌: " + palte + "_" + color.desc);
String connectionUrl = "jdbc:sqlserver://localhost:1433;"
+ "databaseName=AdventureWorks;integratedSecurity=true;";
String url = "jdbc:sqlserver://127.0.0.1:1433;databaseName=chepai;user=sa;password=197905";//以sa身份连接数据库:请根据自己的用户名和密码进行重新设置!!!!!!
@ -74,10 +76,38 @@ public class PlateRecoTest {
System.out.println("尝试建立数据库连接.");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(url);
System.out.println("数据库连接成功!");
String SQL = "INSERT INTO plate(chepaihao,color) VALUES('"+palte+"','"+col+"' )";
System.out.println("数据库连接成功!");
// String SQL = "INSERT INTO Parking_in(number,color) VALUES('"+palte+"','"+col+"' )";
// String SQL = "INSERT INTO Parking_out(number,color,time_in) VALUES('"+palte+"','"+col+"','2020-08-17 12:50:00')";
stmt = con.createStatement();
stmt.executeUpdate(SQL);
// stmt.executeUpdate(SQL);
String time1=null,time2=null;
String SQL = "SELECT * FROM Parking_in";
rs = stmt.executeQuery(SQL);
while(rs.next())
time1=rs.getString("time_in");
System.out.println(time1);
SQL = "SELECT * FROM Parking_out";
rs = stmt.executeQuery(SQL);
while(rs.next())
time2=rs.getString("time_in");
System.out.println(time2);
Count count=new Count();
double cost=count.charging(time1, time2);
System.out.println(palte+"车主您的停车费用为:");
System.out.println(cost+"元");
}
@ -103,7 +133,8 @@ public class PlateRecoTest {
con.close(); //关闭数据库连接
} catch (Exception e) {
}
}
}
Count count=new Count();
// 识别的车牌,保存图片文件 //需要先创建文件夹
String str = "d:/PlateDetect/" + palte + "_"+ color + "_" + System.currentTimeMillis() +".png";
String str1 = "d:/PlateDetect/" + i + ".png";

@ -0,0 +1,80 @@
package com.yuxue.test;
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
public class sql{
String connectionUrl = "jdbc:sqlserver://localhost:1433;"
+ "databaseName=AdventureWorks;integratedSecurity=true;";
String url = "jdbc:sqlserver://127.0.0.1:1433;databaseName=chepai;user=sa;password=197905";//以sa身份连接数据库:请根据自己的用户名和密码进行重新设置!!!!!!
// 声明JDBC对象
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
// 建立数据库连接.
System.out.println("尝试建立数据库连接.");
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(url);
System.out.println("数据库连接成功!");
// String SQL = "INSERT INTO Parking_in(number,color) VALUES('"+palte+"','"+col+"' )";
// String SQL = "INSERT INTO Parking_out(number,color) VALUES('"+palte+"','"+col+"' )";
stmt = con.createStatement();
// stmt.executeUpdate(SQL);
String time1=null,time2=null;
String SQL = "SELECT * FROM Parking_in";
rs = stmt.executeQuery(SQL);
if(rs.next())
time1=rs.getString("time_in");
System.out.println(time1);
SQL = "SELECT * FROM Parking_out";
rs = stmt.executeQuery(SQL);
if(rs.next())
time2=rs.getString("time_in");
System.out.println(time2);
Count count=new Count();
double cost=count.charging(time1, time2);
System.out.println(cost);
}
//处理和打印程序异常
catch (Exception e) {
e.printStackTrace();
}
finally {
if (rs != null)
try {
rs.close(); //关闭查询结果集句柄
} catch (Exception e) {
}
if (stmt != null)
try {
stmt.close(); //关闭语句句柄
} catch (Exception e) {
}
if (con != null)
try {
con.close(); //关闭数据库连接
} catch (Exception e) {
}
}

@ -21,7 +21,7 @@ public class Count {
try {
Date date1 = df.parse(beginReceiveTime);
Date date2 = df.parse(lastReceiveTime);
long diff = date1.getTime() - date2.getTime();
long diff = date2.getTime() - date1.getTime();
long minutes = diff / (1000 * 60);
return minutes;
} catch (Exception e) {

Loading…
Cancel
Save