gpt4 book ai didi

java - 比较 Visual Basic sql 和 Java sql

转载 作者:行者123 更新时间:2023-12-01 04:48:09 26 4
gpt4 key购买 nike

这是我在 Visual Basic(winform 应用程序)上连接项目并触发 SELECT STATEMENT 的方式。对于 SQLSERVER,我现在的问题是我不知道这是否与在 JAVA 应用程序上连接我的项目的方式相同。 (当然我知道应该是 Imports java.sql.* 而不是 Imports System.Data.SqlClient )

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,因为我缺乏有关此类事物的信息。谁能告诉我该怎么做?

最佳答案

您可以使用 Microsoft JDBC Driver for Java 从 Java 连接到 SQL Server:https://msdn.microsoft.com/en-us/sqlserver/aa937724.aspx

您可以在此处查看一些使用 Microsoft JDBC Driver for Java 的示例应用程序:https://msdn.microsoft.com/en-us/library/aa342346%28v=sql.110%29.aspx

关于java - 比较 Visual Basic sql 和 Java sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15469605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com