我正在使用mysql和node.js。我正在尝试获得一个简单的连接,但是却收到此奇怪的错误。我正在使用的代码是这个
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'userlogin'
});
connection.connect();
这是我得到的错误:
这是有关服务器的一些详细信息:
答案 0 :(得分:1)
您是否尝试过在对我有用的工作台中执行此操作
import java.util.Scanner;
public class InvoiceApp {
public static void main(String[] args) {
// welcome the user to the program
System.out.println("Welcome to the Invoice Total Calculator");
System.out.println(); // print a blank line
// create a Scanner object named sc
Scanner sc = new Scanner(System.in);
// perform invoice calculations until choice isn't equal to "y" or "Y"
String choice = "y";
while (choice.equalsIgnoreCase("y")) {
if (choice.equalsIgnoreCase("n")) { // trying to make a Y/N question
}
// get the invoice subtotal from the user
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
// calculate the discount amount and total
double discountPercent = 0;
if (subtotal <= 100) {
discountPercent = .1;
} else if (subtotal <= 200) {
discountPercent = .2;
} else if (subtotal >= 500) {
discountPercent = 0.25;
}
double discountAmount = subtotal * discountPercent;
double total = subtotal - discountAmount;
// display the discount amount and total
String message = "Discount percent: " + discountPercent + "\n"
+ "Discount amount: " + discountAmount + "\n"
+ "Invoice total: " + total + "\n";
System.out.println(message);
// see if the user wants to continue
System.out.print("Continue? (y/n): ");
choice = sc.next();
System.out.println();
}
}
}