Click here to Skip to main content
15,885,216 members
Home / Discussions / Java
   

Java

 
GeneralRe: apriori with java please Pin
Richard MacCutchan11-Apr-17 21:38
mveRichard MacCutchan11-Apr-17 21:38 
GeneralRe: apriori with java please Pin
Nick_314159265419-Apr-17 7:19
Nick_314159265419-Apr-17 7:19 
GeneralRe: apriori with java please Pin
Richard MacCutchan19-Apr-17 23:03
mveRichard MacCutchan19-Apr-17 23:03 
Questionnaive bayes algorithm Pin
Member 131128447-Apr-17 7:11
Member 131128447-Apr-17 7:11 
AnswerRe: naive bayes algorithm Pin
Richard MacCutchan7-Apr-17 21:33
mveRichard MacCutchan7-Apr-17 21:33 
QuestionJava Project Pin
Member 131062494-Apr-17 11:57
Member 131062494-Apr-17 11:57 
AnswerRe: Java Project Pin
Richard MacCutchan6-Apr-17 21:22
mveRichard MacCutchan6-Apr-17 21:22 
QuestionJava connection on microsoft SQL Pin
davordj26-Mar-17 22:32
davordj26-Mar-17 22:32 
Hello,

I am all new to java trying to learn same basic and make same little application.
I am stuck on beginning Smile | :) ) Can't make connection work from java app.
I make connection to server from services (there I may see database).
DB - TEST

ID - int
user - nchar(10)
pass - nchar(10)

But whan trying to run basic app it show
run:
Got an exception! 
com.microsoft.jdbc.sqlserver.SQLServerDriver
BUILD SUCCESSFUL (total time: 0 seconds)



Code is
package javaapp;
import java.sql.*;


public class javaapp
{

  public static void main(String[] args)
  {
    try
    {
      // create our SQL database connection
      String myDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
      String myUrl = "jdbc:sqlserver://core3:1433;databaseName=test";
      Class.forName(myDriver);
      Connection conn = DriverManager.getConnection(myUrl, "test", "test");
      
      // SQL SELECT query. 
      String query = "SELECT * FROM test";

      // create the java statement
      Statement st = conn.createStatement();
      
      // execute the query, and get a java resultset
      ResultSet rs = st.executeQuery(query);
      
      // iterate through the java resultset
      while (rs.next())
      {
        int id = rs.getInt("id");
        String Ime = rs.getString("ime");
        String Pasw = rs.getString("pass");
        
        
        // print the results
        System.out.format("%d, %s %s", id, Ime, Pasw);
      }
      st.close();
    }
    catch (Exception e)
    {
      System.err.println("Got an exception! ");
      System.err.println(e.getMessage());
    }
  }
}


Any tip will be welcome.

I using netbeans 8.2 and have JRE 1.8.0_121
JDBC used sqljdbc42.jar

SuggestionRe: Java connection on microsoft SQL Pin
Richard MacCutchan26-Mar-17 23:00
mveRichard MacCutchan26-Mar-17 23:00 
Questionpc sharing Pin
Member 1306929119-Mar-17 16:15
Member 1306929119-Mar-17 16:15 
AnswerRe: pc sharing Pin
Richard MacCutchan19-Mar-17 22:57
mveRichard MacCutchan19-Mar-17 22:57 
Questiongui components for multipart email Pin
ashoknailwal18-Mar-17 9:03
ashoknailwal18-Mar-17 9:03 
AnswerRe: gui components for multipart email Pin
Richard MacCutchan18-Mar-17 22:02
mveRichard MacCutchan18-Mar-17 22:02 
GeneralRe: gui components for multipart email Pin
ashoknailwal18-Mar-17 23:32
ashoknailwal18-Mar-17 23:32 
GeneralRe: gui components for multipart email Pin
Richard MacCutchan19-Mar-17 2:42
mveRichard MacCutchan19-Mar-17 2:42 
Questiongetting error RuntimeException: instantiationException: Pin
Member 1305920814-Mar-17 12:08
Member 1305920814-Mar-17 12:08 
AnswerRe: getting error RuntimeException: instantiationException: Pin
Richard MacCutchan14-Mar-17 21:51
mveRichard MacCutchan14-Mar-17 21:51 
QuestionClass Structure (3 questions) Pin
ShikadiMaster13-Mar-17 23:09
ShikadiMaster13-Mar-17 23:09 
SuggestionRe: Class Structure (3 questions) Pin
CHill6013-Mar-17 23:15
mveCHill6013-Mar-17 23:15 
Questionto print the occurence of the unique words in a string using java-->why my counter is not working Pin
LOKENDRA YADAV12-Mar-17 0:58
LOKENDRA YADAV12-Mar-17 0:58 
AnswerRe: to print the occurence of the unique words in a string using java-->why my counter is not working Pin
Richard MacCutchan12-Mar-17 21:50
mveRichard MacCutchan12-Mar-17 21:50 
QuestionCreate an HTML file AddCookies.html which contains four text boxes . Pin
Member 1270377511-Mar-17 16:51
Member 1270377511-Mar-17 16:51 
AnswerRe: Create an HTML file AddCookies.html which contains four text boxes . Pin
Richard MacCutchan11-Mar-17 22:06
mveRichard MacCutchan11-Mar-17 22:06 
Questionprogram to find the last occurence of a character in a string without using built in function Pin
LOKENDRA YADAV8-Mar-17 22:15
LOKENDRA YADAV8-Mar-17 22:15 
AnswerRe: program to find the last occurence of a character in a string without using built in function Pin
Jochen Arndt8-Mar-17 22:36
professionalJochen Arndt8-Mar-17 22:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.