1
这是我在Visual Basic(winform应用程序)上连接我的项目并触发SELECT STATEMENT
到SQLSERVER的方式,现在我的问题是我不知道如果这与连接我的项目的方式相同在JAVA应用程序上。 (当然我知道这应该是Imports java.sql.*
代替进口System.Data.SqlClient
)将Visual Basic sql与Java sql比较
Imports System.Data.SqlClient
Try
Dim querystring As String = "SELECT MAX(pIDNo) FROM dbo.Patients"
Using connection As New SqlConnection("Data Source=****;Initial Catalog=****;Persist Security Info=True;User ID=****;Password=****")
Dim command As New SqlCommand(querystring, connection)
connection.Open()
Dim reader As SqlDataReader = command.ExecuteReader
Dim value = String.Empty
While reader.Read
value = reader.GetString(0)
End While
txtPNumber.Text = Today.Year.ToString().Substring(2, 2) & Today.Month.ToString().PadLeft(2, "0") & (Integer.Parse(value.Substring(4, value.Length - 4)) + 1).ToString("D4")
End Using
Catch ex As Exception
txtPNumber.Text = Today.Year.ToString().Substring(2, 2) & Today.Month.ToString().PadLeft(2, "0") & num.ToString("D4")
End Try
这是有点难以了解如何我的Java应用程序连接到SQLSERVER,因为我缺乏信息与suchs事情问候。谁能告诉我该怎么做?
请检查此http:// docs.oracle.com/javase/tutorial/jdbc/basics/index.html – 2013-03-18 04:09:34
@Sudhanshu - 我会在将我的项目连接到SQL SERVER之前完成所有这些工作吗? [链接](http://docs.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html) – 2013-03-18 04:11:06
我想你仍然需要知道在Java中连接数据库的方式 - http:// docs。 oracle.com/javase/tutorial/jdbc/basics/connecting.html – 2013-03-18 04:14:08