File tree Expand file tree Collapse file tree 6 files changed +98
-0
lines changed
Expand file tree Collapse file tree 6 files changed +98
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" path =" src" />
4+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11" >
5+ <attributes >
6+ <attribute name =" module" value =" true" />
7+ </attributes >
8+ </classpathentry >
9+ <classpathentry kind =" lib" path =" C:/Users/ntybl/OneDrive/Desktop/sql java/sqljdbc_11.2/enu/mssql-jdbc-11.2.1.jre11.jar" />
10+ <classpathentry kind =" var" path =" auth86" />
11+ <classpathentry kind =" output" path =" bin" />
12+ </classpath >
Original file line number Diff line number Diff line change 1+ /bin /
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >Java2Sql</name >
4+ <comment ></comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.jdt.core.javabuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ </buildSpec >
14+ <natures >
15+ <nature >org.eclipse.jdt.core.javanature</nature >
16+ </natures >
17+ </projectDescription >
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ encoding/<project>=UTF-8
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode =enabled
3+ org.eclipse.jdt.core.compiler.codegen.targetPlatform =11
4+ org.eclipse.jdt.core.compiler.codegen.unusedLocal =preserve
5+ org.eclipse.jdt.core.compiler.compliance =11
6+ org.eclipse.jdt.core.compiler.debug.lineNumber =generate
7+ org.eclipse.jdt.core.compiler.debug.localVariable =generate
8+ org.eclipse.jdt.core.compiler.debug.sourceFile =generate
9+ org.eclipse.jdt.core.compiler.problem.assertIdentifier =error
10+ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures =disabled
11+ org.eclipse.jdt.core.compiler.problem.enumIdentifier =error
12+ org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures =warning
13+ org.eclipse.jdt.core.compiler.release =enabled
14+ org.eclipse.jdt.core.compiler.source =11
Original file line number Diff line number Diff line change 1+ package JavaInSql ;
2+
3+ import java .sql .Connection ;
4+ import java .sql .DriverManager ;
5+ import java .sql .SQLException ;
6+ import java .sql .Statement ;
7+
8+ public class Connect2Sql {
9+
10+ public static void main (String [] args ) {
11+ // TODO Auto-generated method stub
12+
13+ //Properties to connect to the sql data base
14+
15+ String url = "jdbc:sqlserver://desktop-ia0gdad\\ sqlexpress;databaseName=airport;integratedSecurity=false;trustServerCertificate=true" ;
16+ String user = "sa" ;
17+ String password = "nty081200" ;
18+
19+
20+ // Try catch blocks for connection or error
21+
22+ try {
23+ Connection connection = DriverManager .getConnection (url , user , password );
24+ System .out .println ("Connected" );
25+
26+ //Sql command which will affect the sql table in sql program
27+
28+ String sql = "EXECUTE ADD_CUSTOMER 'Melissa', 'Brown', 'Boston'" ;
29+
30+ Statement statement = connection .createStatement ();
31+ int rows = statement .executeUpdate (sql );
32+
33+ // Message that will appear if the command is successful if the row is affected.
34+ if (rows > 0 ) {
35+ System .out .print ("Row was added. " );
36+ }
37+
38+ //Close connection
39+ connection .close ();
40+
41+
42+ //exception to the try block
43+ } catch (SQLException e ) {
44+ System .out .println ("Error" );
45+ e .printStackTrace ();
46+
47+ }
48+
49+
50+ }
51+
52+ }
You can’t perform that action at this time.
0 commit comments